1 27 28 package org.objectweb.speedo.query.lib; 29 30 import java.io.CharArrayReader ; 31 import java.util.ArrayList ; 32 import java.util.Collection ; 33 import java.util.Collections ; 34 import java.util.HashMap ; 35 import java.util.Iterator ; 36 import java.util.Map ; 37 import java.util.StringTokenizer ; 38 39 import javax.jdo.JDOException; 40 import javax.jdo.JDOUserException; 41 42 import org.objectweb.jorm.api.PClassMapping; 43 import org.objectweb.jorm.api.PException; 44 import org.objectweb.jorm.api.PMapper; 45 import org.objectweb.jorm.lib.JormPathHelper; 46 import org.objectweb.jorm.metainfo.api.Manager; 47 import org.objectweb.jorm.naming.api.PName; 48 import org.objectweb.jorm.type.api.PType; 49 import org.objectweb.jorm.type.api.PTypeSpace; 50 import org.objectweb.medor.api.EvaluationException; 51 import org.objectweb.medor.api.MedorException; 52 import org.objectweb.medor.eval.lib.MedorEvaluator; 53 import org.objectweb.medor.eval.prefetch.api.PrefetchBufferFactory; 54 import org.objectweb.medor.expression.api.Expression; 55 import org.objectweb.medor.expression.api.ExpressionException; 56 import org.objectweb.medor.expression.api.Operand; 57 import org.objectweb.medor.expression.api.Operator; 58 import org.objectweb.medor.expression.api.ParameterOperand; 59 import org.objectweb.medor.expression.lib.And; 60 import org.objectweb.medor.expression.lib.BasicParameterOperand; 61 import org.objectweb.medor.expression.lib.ConditionalAnd; 62 import org.objectweb.medor.expression.lib.Equal; 63 import org.objectweb.medor.filter.api.FieldOperand; 64 import org.objectweb.medor.optim.api.QueryTransformer; 65 import org.objectweb.medor.optim.jorm.Jorm2Rdb; 66 import org.objectweb.medor.optim.lib.BasicQueryRewriter; 67 import org.objectweb.medor.optim.lib.FlattenQueryTreeRule; 68 import org.objectweb.medor.optim.lib.IndexesGenerator; 69 import org.objectweb.medor.optim.lib.PushNotInExpressionRule; 70 import org.objectweb.medor.query.api.OrderField; 71 import org.objectweb.medor.query.api.QueryTree; 72 import org.objectweb.medor.query.api.QueryTreeField; 73 import org.objectweb.medor.query.jorm.api.JormExtent; 74 import org.objectweb.medor.query.jorm.lib.JormQueryTreeHelper; 75 import org.objectweb.medor.query.jorm.lib.QueryBuilder; 76 import org.objectweb.medor.query.lib.BasicOrderField; 77 import org.objectweb.medor.query.lib.QueryTreePrinter; 78 import org.objectweb.medor.query.lib.SelectProject; 79 import org.objectweb.medor.tuple.api.TupleCollection; 80 import org.objectweb.medor.type.lib.PTypeSpaceMedor; 81 import org.objectweb.medor.type.lib.QType; 82 import org.objectweb.perseus.cache.api.UnFixProtocolException; 83 import org.objectweb.perseus.cache.replacement.api.ReplaceableCacheEntry; 84 import org.objectweb.perseus.persistence.api.PersistenceException; 85 import org.objectweb.perseus.persistence.api.State; 86 import org.objectweb.perseus.persistence.api.StateFilter; 87 import org.objectweb.speedo.api.SpeedoException; 88 import org.objectweb.speedo.mapper.api.JormFactory; 89 import org.objectweb.speedo.mapper.lib.DelegatePMapper; 90 import org.objectweb.speedo.mim.api.SpeedoHome; 91 import org.objectweb.speedo.mim.api.SpeedoProxy; 92 import org.objectweb.speedo.pm.api.ProxyManager; 93 import org.objectweb.speedo.query.api.CompiledQuery; 94 import org.objectweb.speedo.query.api.QueryDefinition; 95 import org.objectweb.speedo.query.parser.ASTSpeedoQL; 96 import org.objectweb.speedo.query.parser.ParseException; 97 import org.objectweb.speedo.query.parser.SelectGroupByVisitor; 98 import org.objectweb.speedo.query.parser.SimpleNode; 99 import org.objectweb.speedo.query.parser.SpeedoQL; 100 import org.objectweb.speedo.query.parser.SpeedoQLQueryFilterVisitor; 101 import org.objectweb.speedo.query.parser.SpeedoQLVariableVisitor; 102 import org.objectweb.speedo.usercache.api.UserCache; 103 import org.objectweb.speedo.usercache.lib.UserCacheKey; 104 import org.objectweb.speedo.workingset.api.Transaction; 105 import org.objectweb.util.monolog.api.BasicLevel; 106 import org.objectweb.util.monolog.api.Logger; 107 108 116 public class SpeedoCompiledQuery 117 implements CompiledQuery, StateFilter, ReplaceableCacheEntry { 118 119 private short status; 120 private ClassLoader classLoader; 121 122 125 private QueryDefinitionImpl qd = null; 126 127 131 private Map hparams = null; 132 private Map paramName2paramClass = null; 133 private Map hvars = null; 134 private QueryEvalContext[] qecs = null; 135 private Class [] selectedFieldTypes = null; 136 137 140 142 private Collection pncParams = null; 143 146 private Logger logger = null; 147 private Logger varParserlogger = null; 148 private Logger filterParserLogger = null; 149 150 private DelegatePMapper mapper = null; 151 private JormFactory jf; 152 private PrefetchBufferFactory prefetchBufferFactory; 153 private UserCache userCache = null; 154 private Operand[] userCacheIndexes = null; 155 156 157 private long age = 0; 158 private int fixCount = 0; 159 160 161 public void init(Logger l, 162 Logger logParserVar, 163 Logger logParserFil, 164 PMapper m, 165 PrefetchBufferFactory pbf, 166 JormFactory _jf) { 167 logger = l; 168 varParserlogger = logParserVar; 169 filterParserLogger = logParserFil; 170 mapper = new DelegatePMapper(m); 171 setJormFactory(_jf); 172 this.prefetchBufferFactory = pbf; 173 } 174 175 public PMapper getMapper() { 176 return mapper; 177 } 178 179 public void setMapper(PMapper m) { 180 mapper = new DelegatePMapper(m); 181 if (jf != null) { 182 mapper.setJormFactory(jf); 183 } 184 } 185 186 public void setJormFactory(JormFactory jf) { 187 this.jf = jf; 188 if (mapper != null) { 189 mapper.setJormFactory(jf); 190 } 191 } 192 193 public Logger getLogger() { 194 return logger; 195 } 196 197 public QueryEvalContext[] getQueryEvalContext() { 198 return qecs; 199 } 200 201 public PrefetchBufferFactory getPrefetchBufferFactory() { 202 return prefetchBufferFactory; 203 } 204 205 public boolean isPrefetchResult() { 206 return qd.withPrefetch; 207 } 208 209 public void defineQuery(QueryDefinition _qd) { 210 this.qd = new QueryDefinitionImpl(_qd); 211 classLoader = _qd.getCandidateClass().getClassLoader(); 212 if (classLoader == null) { 213 classLoader = getClass().getClassLoader(); 214 if (classLoader == null) { 215 classLoader = ClassLoader.getSystemClassLoader(); 216 logger.log(BasicLevel.DEBUG, "The system classLoader of the " + 217 "class is assigned to the query: " + classLoader); 218 } else { 219 logger.log(BasicLevel.DEBUG, "The classLoader of Speedo is" + 220 " assigned the query: " + classLoader); 221 } 222 } else { 223 logger.log(BasicLevel.DEBUG, "The classLoader of the class is " + 224 "assigned to the query: " + classLoader); 225 } 226 mapper.setClassLoader(classLoader); 227 status = DEFINED; 228 } 229 230 public long getCeAge() { 233 return age; 234 } 235 236 public void setCeAge(long _age) { 237 this.age = _age; 238 } 239 240 public void fixCe() { 241 fixCount++; 242 } 243 244 public void unfixCe() throws UnFixProtocolException { 245 fixCount--; 246 } 247 248 public int getCeFixCount() { 249 return fixCount; 250 } 251 252 public Object getCeObject() { 253 return this; 254 } 255 256 public Object getCeIdentifier() { 257 return qd; 258 } 259 260 public synchronized QueryDefinition getDefinition() { 263 switch(status) { 264 case DEFINED: 265 case COMPILED: 266 return qd; 267 case UNDEFINED: 268 default: 269 return null; 270 } 271 } 272 273 279 public synchronized void compile() throws SpeedoException, MedorException, ExpressionException { 280 if (status == UNDEFINED) 281 throw new SpeedoException("Impossible to compile an undefined query"); 282 if (status == COMPILED) 283 return; 284 long timeToCompile = System.currentTimeMillis(); 285 boolean debug = logger.isLoggable(BasicLevel.DEBUG); 286 String filter = qd.filter; 288 filter = '(' + filter + ')'; 289 toHashtableParams(qd.parameters, ";,"); 292 toHashtableVars(qd.variables, ";,"); 293 Manager miManager = mapper.getMetaInfoManager(); 294 if (miManager == null) 295 throw new SpeedoException( 296 "A non null Meta information manager is needed"); 297 try { 298 jf.getPClassMapping( 299 qd.candidateClass.getName(), 300 classLoader); 301 } catch (Exception e) { 302 throw new SpeedoException(e); 303 } 304 SimpleNode node = null; 305 try { 306 node = new SpeedoQL(new CharArrayReader (filter.toCharArray())).SpeedoQL(); 307 } catch (ParseException e) { 308 throw new SpeedoException( 309 "Impossible to parse the filter and to create AST", e); 310 } 311 SpeedoQLVariableVisitor sqvv = new SpeedoQLVariableVisitor( 312 node, miManager, varParserlogger, hparams, hvars, qd.order, 313 qd.candidateClass.getName(), qd.includeSubClasses); 314 Map fields = sqvv.getFields(); 317 QueryBuilder qb = sqvv.getQueryBuilder(); 318 QueryTree qt = sqvv.getQueryTree(); 319 320 SelectProject sp = new SelectProject(""); 321 if (!filter.equals("(true)") && !filter.equals("true")) { 322 if (debug) { 324 logger.log(BasicLevel.DEBUG, "filter = " + qd.filter); 325 } 326 SpeedoQLQueryFilterVisitor sqfv = new SpeedoQLQueryFilterVisitor( 329 fields, sp, (ASTSpeedoQL) node, 330 filterParserLogger, hparams, hvars, 331 qd.candidateClass, 332 qb, jf); 333 sp.setQueryFilter(sqfv.getQueryFilter()); 334 } 335 assignMapper(sp); 336 assignMapper(qt); 337 338 QueryEvalContext qec = new QueryEvalContext(sp, this); 339 340 SelectGroupByVisitor sgv = new SelectGroupByVisitor( 341 sp, qt, mapper, sqvv, qd, qec, classLoader); 342 343 sgv.visit(qd); 344 selectedFieldTypes = sgv.getSelectFieldTypes(); 345 assignMapper(qec.query); 346 347 if (qd.order != null && qd.order.size() > 0) { 349 OrderField[] ofs = new OrderField[qd.order.size()]; 350 for(int i=0; i<ofs.length; i++) { 351 String o = (String ) qd.order.get(i); 352 int idx = o.indexOf(' '); 353 boolean desc = false; 354 if (idx != -1) { 355 desc = o.substring(idx + 1).trim().equals("descending"); 356 o = o.substring(0, idx); 357 } 358 o = "this." + o; 359 ofs[i] = new BasicOrderField((QueryTreeField) 360 qt.getTupleStructure().getField(o), desc); 361 } 362 sp.setOrderBy(ofs); 363 } 364 365 logger.log(BasicLevel.INFO, "QueryTree built"); 366 if (debug) { 367 QueryTreePrinter.printQueryTree(qec.query, logger); 368 } 369 if (qd.result == null && qd.variables == null) { 371 Map field2value = new HashMap (); 373 if (getFieldComparaison(sp.getQueryFilter(), field2value)) { 374 SpeedoHome sh = null; 375 try { 376 sh = (SpeedoHome) jf.getPClassMapping( 377 qd.candidateClass.getName(), 378 classLoader); 379 } catch (PException e) { 380 } 382 userCache = sh.getUserCache(field2value.keySet()); 383 if (userCache != null) { 384 userCacheIndexes = new Operand[field2value.size()]; 385 String [] ifs = userCache.getIndexFieldNames(); 386 for (int i = 0; i < ifs.length; i++) { 387 userCacheIndexes[i] = (Operand) field2value.get(ifs[i]); 388 } 389 } 390 } 391 392 } 393 394 optimize(qec, debug); 396 397 qec.evaluator = new MedorEvaluator(qec.query, 0); 399 400 qecs = new QueryEvalContext[] {qec}; 401 timeToCompile = System.currentTimeMillis() - timeToCompile; 402 status = COMPILED; 403 logger.log(BasicLevel.INFO, "Query compiled in " + timeToCompile + "ms"); 404 } 405 406 private boolean getFieldComparaison(Expression e, Map field2value) { 407 if (e instanceof And || e instanceof ConditionalAnd) { 408 return getFieldComparaison(((Operator) e).getExpression(0), field2value) 409 && getFieldComparaison(((Operator) e).getExpression(1), field2value); 410 } else if (e instanceof Equal){ 411 Expression tmpe = ((Operator) e).getExpression(0); 412 if (!(tmpe instanceof Operand)) { 413 return false; 414 } 415 Operand op0 = (Operand) tmpe; 416 tmpe = ((Operator) e).getExpression(1); 417 if (!(tmpe instanceof Operand)) { 418 return false; 419 } 420 Operand op1 = (Operand) tmpe; 421 if (op0 instanceof FieldOperand) { 423 } else if (op1 instanceof FieldOperand) { 424 Operand o = op0; 426 op0 = op1; 427 op1 = o; 428 } else { 429 return false; 430 } 431 if (op1 instanceof FieldOperand) { 433 return false; 434 } 435 String fieldName = ((FieldOperand) op0).getField().getName(); 437 if (fieldName.indexOf('.') != -1) { if (fieldName.startsWith("this.")) { fieldName = fieldName.substring(5); } 441 if (fieldName.indexOf('.') != -1) { return false; 443 } 444 } 445 field2value.put(fieldName, op1); 446 return true; 447 } 448 return false; 449 } 450 451 452 457 private void assignMapper(QueryTree qt)throws SpeedoException { 458 Collection extents = JormQueryTreeHelper.getJormExtents(qt); 460 boolean debug = logger.isLoggable(BasicLevel.DEBUG); 461 if (debug) { 462 logger.log(BasicLevel.DEBUG, "Extent nodes: " + extents.size()); 463 } 464 for (Iterator it = extents.iterator(); it.hasNext();) { 465 JormExtent je = (JormExtent) it.next(); 466 try { 467 PClassMapping pcm = jf.getPClassMapping( 468 JormPathHelper.getOriginClass(je.getJormName()), 469 classLoader); 470 if (debug) { 471 logger.log(BasicLevel.DEBUG, 472 "JormExtent: " + je + " / pcm=" + pcm); 473 } 474 je.setPMapper(pcm.getPMapper(), pcm.getProjectName()); 475 } catch (PException e) { 476 throw new SpeedoException( 477 "Error while fetching PClassPMapping of the class " 478 + je.getJormName(), e); 479 } 480 } 481 } 482 483 private void optimize(QueryEvalContext pqc, boolean debug) 484 throws MedorException, ExpressionException { 485 ArrayList rules = new ArrayList (); 486 rules.add(new PushNotInExpressionRule()); 487 rules.add(new FlattenQueryTreeRule()); 488 rules.add(new Jorm2Rdb()); 490 QueryTransformer queryTransformer = new BasicQueryRewriter(rules); 491 IndexesGenerator indexesGenerator = new IndexesGenerator(); 492 try { 493 pqc.query = queryTransformer.transform(pqc.query); 494 if (debug) { 495 logger.log(BasicLevel.DEBUG, "Query optimized"); 496 QueryTreePrinter.printQueryTree(pqc.query, logger); 497 } 498 pqc.query = indexesGenerator.transform(pqc.query); 499 } catch (Exception e) { 500 throw new MedorException("Impossible to optimize the query", e); 501 } 502 503 pncParams = JormQueryTreeHelper.getRequiredPNameManagers(pqc.query); 504 for (Iterator it = pncParams.iterator(); it.hasNext();) { 505 ParameterOperand po = (ParameterOperand) it.next(); 506 String name = po.getName(); 507 if (debug) { 508 logger.log(BasicLevel.DEBUG, "ParameterOperand " + name + " is expected."); 509 } 510 po.setValue(JormPathHelper.getPNameCoder(name, mapper)); 511 } 512 } 513 514 515 524 public Object execute(Object [] a, ProxyManager pm, QueryDefinition userqd) 525 throws SpeedoException, MedorException, ExpressionException { 526 if (status != COMPILED) 527 throw new EvaluationException( 528 "Impossible to execute a query if it has not been defined and compiled before"); 529 ParameterOperand[] pos = null; 530 if (a != null) { 531 pos = new ParameterOperand[a.length + pncParams.size()]; 532 for(Iterator it = hparams.values().iterator(); it.hasNext();) { 533 Object [] o = (Object []) it.next(); 534 int idx = ((Integer ) o[0]).intValue(); 535 pos[idx] = new BasicParameterOperand( 536 (BasicParameterOperand) o[1]); 537 treatParameter(pos[idx], a[idx]); 538 } 539 } else { 540 pos = new ParameterOperand[pncParams.size()]; 541 } 542 if (pncParams.size() >0) { 543 int i = (a == null ? 0 : a.length); 544 for (Iterator it = pncParams.iterator(); it.hasNext(); i++) { 545 pos[i++] = (ParameterOperand) it.next(); 546 } 547 } 548 return executeQT(pm, pos, userqd); 549 } 550 551 552 560 public Object execute(Map m, ProxyManager pm, QueryDefinition userqd) 561 throws SpeedoException, MedorException, ExpressionException { 562 if (status != COMPILED) 563 throw new EvaluationException( 564 "Impossible to execute a query if it has not been defined and compiled before"); 565 ParameterOperand[] pos = 566 new BasicParameterOperand[m.size() + pncParams.size()]; 567 for(Iterator it = hparams.values().iterator(); it.hasNext();) { 568 Object [] o = (Object []) it.next(); 569 int idx = ((Integer ) o[0]).intValue(); 570 pos[idx] = new BasicParameterOperand( 571 (BasicParameterOperand) o[1]); 572 treatParameter(pos[idx], m.get(pos[idx].getName())); 573 } 574 if (pncParams.size() >0) { 575 int i = (m == null ? 0 : m.size()); 576 for (Iterator it = pncParams.iterator(); it.hasNext(); i++) { 577 pos[i++] = (ParameterOperand) it.next(); 578 } 579 } 580 return executeQT(pm, pos, userqd); 581 } 582 583 private void treatParameter(ParameterOperand po, Object value) 584 throws SpeedoException, ExpressionException { 585 Object val = value; 586 if (po.getType().getTypeCode() == QType.TYPECODE_PNAME) { 587 if (val == null) { 589 try { 590 val = 591 jf.getPClassMapping( 592 (Class ) paramName2paramClass.get(po.getName())) 593 .getPBinder().getNull(); 594 } catch (Exception e) { 595 throw new SpeedoException( 596 "Impossible to find the null PName of the parameter (name= " 597 + po.getName() 598 + " / type= " + po.getType().getJormName(), 599 e); 600 } 601 } else if (val instanceof SpeedoProxy) { 602 val = ((SpeedoProxy) value).getPName(); 603 } else { 604 throw new JDOUserException("The parameter '" 605 + po.getName() 606 + "' must be a persistent object: " + val); 607 } 608 } 609 po.setValue(val); 610 } 611 612 public short getStatus() { 613 return status; 614 } 615 616 619 632 private void toHashtableParams(String stringToHash, String separator) { 633 hparams = new HashMap (); 634 paramName2paramClass = new HashMap (); 635 if (stringToHash != null) { 636 StringTokenizer tok = new StringTokenizer (stringToHash, separator); 637 int idx = 0; 638 while (tok.hasMoreTokens()) { 639 String tuple = tok.nextToken().trim(); 640 int i = tuple.indexOf(' '); 641 String name = tuple.substring(i + 1, tuple.length()); 642 String paramType = tuple.substring(0, i).trim(); 643 PType type = getPType(paramType); 644 hparams.put(name, new Object []{ 645 new Integer (idx), 646 new BasicParameterOperand(type, name)}); 647 idx ++; 648 if (type == PTypeSpaceMedor.PNAME) { 649 paramName2paramClass.put(name, getClass(paramType)); 650 } 651 } 652 } 653 } 654 655 private void toHashtableVars(String stringToHash, String separator) { 656 hvars = new HashMap (); 657 if (stringToHash != null) { 658 StringTokenizer tok = new StringTokenizer (stringToHash, separator); 659 while (tok.hasMoreTokens()) { 660 String tuple = tok.nextToken().trim(); 661 int i = tuple.indexOf(' '); 662 String type = tuple.substring(0, i); 663 hvars.put(tuple.substring(i + 1, tuple.length()), type); 664 } 665 } 666 } 667 668 private PType getPType(String name) { 669 if ("String".equals(name)) { 670 return PTypeSpace.STRING; 671 } 672 if ("Integer".equals(name)) { 673 return PTypeSpace.OBJINT; 674 } 675 for (int i = 0; i < PTypeSpace.PREDEFINEDPTYPES.length; i++) { 676 PType type = PTypeSpace.PREDEFINEDPTYPES[i]; 677 if (type.getJavaName().equals(name) 678 || type.getJormName().equals(name)) { 679 return type; 680 } 681 } 682 if ("Collection".equals(name) 683 || PTypeSpaceMedor.COLLECTION.getJavaName().equals(name)) { 684 return PTypeSpaceMedor.COLLECTION; 685 } 686 return PTypeSpaceMedor.PNAME; 687 } 688 private Class getClass(String classname) { 689 if (classLoader != null) { 690 try { 691 return classLoader.loadClass(classname); 692 } catch (ClassNotFoundException e) { 693 try { 694 return classLoader.loadClass( 695 qd.candidateClass.getPackage().getName() + "." + classname); 696 } catch (ClassNotFoundException e2) { 697 return null; 698 } 699 } 700 } else { 701 return null; 702 } 703 } 704 705 713 private Object executeQT(ProxyManager pm, ParameterOperand[] pos, QueryDefinition userqd) 714 throws EvaluationException, MedorException, SpeedoException { 715 if (!qd.ignoreCache || !pm.getIgnoreCache()) { 716 if (logger.isLoggable(BasicLevel.DEBUG)) { 717 logger.log(BasicLevel.DEBUG, 718 "Flush dirty instances of the working set ..."); 719 } 720 try { 721 pm.getTransactionalPersistenceManager() 722 .flush((Transaction) pm.currentTransaction(), this); 723 } catch (PersistenceException e) { 724 throw new JDOException("Impossible to use the cache into a " + 725 "query: Error during the flushing of data on the support", e); 726 } 727 } 728 if (userCache != null) { Object key = null; 730 if (userCacheIndexes.length == 1) { 732 key = getValueFromOperand(userCacheIndexes[0], pos); 734 } else { 735 key = new UserCacheKey(userCacheIndexes.length); 737 for (int i = 0; i < userCacheIndexes.length; i++) { 738 ((UserCacheKey) key).setPart(i, 739 getValueFromOperand(userCacheIndexes[0], pos)); 740 } 741 } 742 key = userCache.lookup(key); 744 if (key != null) { 745 try { 746 if (key instanceof PName) { key = pm.getObjectById(key, false); 748 } 749 if (qd.unique) { 750 return key; 751 } else { 752 return Collections.singletonList(key); 753 } 754 } catch (JDOException e) { 755 logger.log(BasicLevel.WARN, 756 "User cache is not up to date:", e); 757 } 758 } 759 } 760 761 Object connection = ((Transaction) pm.currentTransaction()) 762 .getConnectionHolder(); 763 TupleCollection queryResult = null; 764 if (qecs.length == 1) { 765 queryResult = qecs[0].eval(pm, pos, connection, userqd); 767 if (queryResult == null || queryResult.isEmpty()) { 768 logger.log(BasicLevel.INFO, 769 "Be careful, the result is empty"); 770 if (queryResult != null) { 771 queryResult.close(); 772 } 773 QueryResultCommon.closeConnection(connection); 774 if (qd.unique) { 775 return null; 776 } else { 777 return Collections.EMPTY_SET; 778 } 779 } 780 } else { 781 queryResult = new QueriesUnion(pos, pm, connection, qecs, userqd); 783 } 784 if (qd.unique) { 785 return new QueryResultUnique( 786 queryResult, 787 pm, 788 new Object []{connection}, 789 qd.resultClass, 790 selectedFieldTypes, 791 qecs.length == 1, 792 logger).getResult(); 793 } else { 794 return new QueryResultList( 795 queryResult, 796 pm, 797 new Object []{connection}, 798 qd.resultClass, 799 selectedFieldTypes, 800 qecs.length == 1, 801 logger); 802 } 803 } 804 805 private Object getValueFromOperand(Operand op, ParameterOperand[] pos) { 806 if (op instanceof ParameterOperand) { 807 String param = ((ParameterOperand) op).getName(); 808 for (int i = 0; i < pos.length; i++) { 809 if (pos[i].getName().equals(param)) { 810 return pos[i].getObject(); 811 } 812 } 813 return null; 814 } else { 815 return op.getObject(); 816 } 817 } 818 819 822 public boolean accept(State ce) { 823 if (logger.isLoggable(BasicLevel.DEBUG)) { 824 logger.log(BasicLevel.DEBUG, 825 "Flush dirty instance of the working state, identifier: " 826 + ce.getCacheEntry().getCeIdentifier()); 827 } 828 return true; 829 } 830 831 832 } | Popular Tags |