1 /* 2 Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. 3 4 This program is free software; you can redistribute it and/or modify 5 it under the terms of the GNU General Public License, version 2.0, 6 as published by the Free Software Foundation. 7 8 This program is also distributed with certain software (including 9 but not limited to OpenSSL) that is licensed under separate terms, 10 as designated in a particular file or component or in included license 11 documentation. The authors of MySQL hereby grant you an additional 12 permission to link the program and your derivative works with the 13 separately licensed software that they have included with MySQL. 14 15 This program is distributed in the hope that it will be useful, 16 but WITHOUT ANY WARRANTY; without even the implied warranty of 17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 GNU General Public License, version 2.0, for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software 22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 23 */ 24 25 package testsuite.clusterj; 26 27 import com.mysql.clusterj.Query; 28 import com.mysql.clusterj.Session; 29 30 import com.mysql.clusterj.query.QueryBuilder; 31 import com.mysql.clusterj.query.QueryDomainType; 32 import com.mysql.clusterj.query.Predicate; 33 import com.mysql.clusterj.query.PredicateOperand; 34 35 import java.util.ArrayList; 36 import java.util.HashSet; 37 import java.util.List; 38 import java.util.Set; 39 40 import testsuite.clusterj.model.IdBase; 41 42 abstract public class AbstractQueryTest extends AbstractClusterJModelTest { 43 44 /** 45 * Create instances required by the test, used for the queries. 46 * @param number the number of instances to create 47 */ createInstances(int number)48 abstract void createInstances(int number); 49 50 /** Most query tests use the same number of instances (10). 51 * 52 */ 53 @Override getNumberOfInstances()54 protected int getNumberOfInstances() { 55 return 10; 56 } 57 58 /** 59 * Return the type of instances used for the queries. 60 * @return the type of instances for the test 61 */ getInstanceType()62 abstract Class<?> getInstanceType(); 63 64 /** The QueryHolder for this test */ 65 protected QueryHolder holder; 66 67 private boolean autotransaction; 68 69 /** The lower limit (number of returned rows to skip) */ 70 protected Long skip = null; 71 72 /** The upper limit (number of rows to return) */ 73 protected Long limit = null; 74 75 /** The ordering for the query */ 76 protected Query.Ordering ordering = null; 77 78 /** The ordering fields for the query */ 79 protected String[] orderingFields = null; 80 81 @Override localSetUp()82 public void localSetUp() { 83 setAutotransaction(false); 84 createSessionFactory(); 85 session = sessionFactory.getSession(); 86 tx = session.currentTransaction(); 87 int numberOfInstances = getNumberOfInstances(); 88 createInstances(numberOfInstances); 89 session.deletePersistentAll(getInstanceType()); 90 session.makePersistentAll(instances); 91 if (getCleanupAfterTest()) 92 addTearDownClasses(getInstanceType()); 93 } 94 setAutotransaction(boolean b)95 protected void setAutotransaction(boolean b) { 96 autotransaction = b; 97 } 98 setLimit(long limit)99 protected void setLimit(long limit) { 100 this.skip = null; 101 this.limit = limit; 102 } 103 setLimits(long skip, long limit)104 protected void setLimits(long skip, long limit) { 105 this.skip = skip; 106 this.limit = limit; 107 } 108 setOrdering(Query.Ordering ordering, String... orderingFields)109 protected void setOrdering(Query.Ordering ordering, String... orderingFields) { 110 this.ordering = ordering; 111 this.orderingFields = orderingFields; 112 } 113 114 class QueryHolder { 115 public QueryBuilder builder; 116 public QueryDomainType<?> dobj; 117 public String propertyName; 118 public String extraPropertyName; 119 public PredicateOperand propertyPredicate; 120 public PredicateOperand paramEqualPredicate; 121 public PredicateOperand paramLowerPredicate; 122 public PredicateOperand paramUpperPredicate; 123 public PredicateOperand paramInPredicate; 124 public Predicate equal; 125 public Predicate isNull; 126 public Predicate isNotNull; 127 public Predicate equalOrEqual; 128 public Predicate greaterThan; 129 public Predicate greaterEqual; 130 public Predicate in; 131 public Predicate lessThan; 132 public Predicate lessEqual; 133 public Predicate between; 134 public Predicate greaterThanAndLessThan; 135 public Predicate greaterEqualAndLessThan; 136 public Predicate greaterThanAndLessEqual; 137 public Predicate greaterThanAndLike; 138 public Predicate greaterEqualAndLessEqual; 139 public Predicate greaterEqualAndLike; 140 public Predicate notEqual; 141 public Predicate notGreaterThan; 142 public Predicate notGreaterEqual; 143 public Predicate notLessThan; 144 public Predicate notLessEqual; 145 public Predicate notBetween; 146 public Predicate like; 147 public Predicate greaterThanAndNotGreaterThan; 148 public Predicate greaterEqualAndNotGreaterThan; 149 public Predicate greaterThanAndNotGreaterEqual; 150 public Predicate greaterEqualAndNotGreaterEqual; 151 public PredicateOperand extraParamEqualPredicate; 152 public PredicateOperand extraParamLowerPredicate; 153 public PredicateOperand extraParamUpperPredicate; 154 public PredicateOperand extraParamInPredicate; 155 public PredicateOperand extraProperty; 156 public Predicate extraEqual; 157 public Predicate extraIsNull; 158 public Predicate extraIsNotNull; 159 public Predicate extraGreaterThan; 160 public Predicate extraGreaterEqual; 161 public Predicate extraLessThan; 162 public Predicate extraLessEqual; 163 public Predicate extraBetween; 164 public Predicate extraGreaterThanAndLessThan; 165 public Predicate extraGreaterEqualAndLessThan; 166 public Predicate extraGreaterThanAndLessEqual; 167 public Predicate extraGreaterEqualAndLessEqual; 168 public Query<?> query; 169 public Set<Integer> expectedSet = new HashSet<Integer>(); 170 public List<Integer> expectedList = new ArrayList<Integer>(); 171 public List<IdBase> resultList; 172 public String expectedIndex; 173 private Predicate equalOrIn; 174 private Predicate extraIn; 175 private Predicate inAndIn; 176 private Predicate inAndBetween; 177 private Predicate betweenAndIn; QueryHolder(Class<?> type, String propertyName, String expectedIndex)178 public QueryHolder(Class<?> type, String propertyName, String expectedIndex) { 179 this.propertyName = propertyName; 180 // QueryBuilder is the sessionFactory for queries 181 builder = session.getQueryBuilder(); 182 // QueryDomainType is the main interface 183 dobj = builder.createQueryDefinition(type); 184 this.expectedIndex = expectedIndex; 185 // parameter 186 paramEqualPredicate = dobj.param("equal"); 187 paramLowerPredicate = dobj.param("lower"); 188 paramUpperPredicate = dobj.param("upper"); 189 paramInPredicate = dobj.param("in"); 190 // property 191 propertyPredicate = dobj.get(propertyName); 192 // comparison operations 193 equal = propertyPredicate.equal(paramEqualPredicate); 194 isNull = propertyPredicate.isNull(); 195 isNotNull = propertyPredicate.isNotNull(); 196 greaterThan = propertyPredicate.greaterThan(paramLowerPredicate); 197 greaterEqual = propertyPredicate.greaterEqual(paramLowerPredicate); 198 lessThan = propertyPredicate.lessThan(paramUpperPredicate); 199 lessEqual = propertyPredicate.lessEqual(paramUpperPredicate); 200 between = propertyPredicate.between(paramLowerPredicate, paramUpperPredicate); 201 greaterThanAndLessThan = lessThan.and(greaterThan); 202 greaterEqualAndLessThan = lessThan.and(greaterEqual); 203 greaterThanAndLessEqual = lessEqual.and(greaterThan); 204 greaterEqualAndLessEqual = lessEqual.and(greaterEqual); 205 in = propertyPredicate.in(paramInPredicate); 206 notEqual = equal.not(); 207 notGreaterThan = greaterThan.not(); 208 notGreaterEqual = greaterEqual.not(); 209 notLessThan = lessThan.not(); 210 notLessEqual = lessEqual.not(); 211 notBetween = between.not(); 212 like = propertyPredicate.like(paramEqualPredicate); 213 greaterThanAndNotGreaterThan = greaterThan.and(propertyPredicate.greaterThan(paramUpperPredicate).not()); 214 greaterEqualAndNotGreaterThan = greaterEqual.and(propertyPredicate.greaterThan(paramUpperPredicate).not()); 215 greaterThanAndNotGreaterEqual = greaterThan.and(propertyPredicate.greaterEqual(paramUpperPredicate).not()); 216 greaterEqualAndNotGreaterEqual = greaterEqual.and(propertyPredicate.greaterEqual(paramUpperPredicate).not()); 217 greaterThanAndLike = greaterThan.and(propertyPredicate.like(paramUpperPredicate)); 218 greaterEqualAndLike = greaterEqual.and(propertyPredicate.like(paramUpperPredicate)); 219 } QueryHolder(Class<?> type, String propertyName, String expectedIndex, String extraPropertyName)220 public QueryHolder(Class<?> type, String propertyName, String expectedIndex, 221 String extraPropertyName) { 222 this(type, propertyName, expectedIndex); 223 this.extraPropertyName = extraPropertyName; 224 this.extraParamEqualPredicate = dobj.param("extraEqual"); 225 this.extraParamLowerPredicate = dobj.param("extraLower"); 226 this.extraParamUpperPredicate = dobj.param("extraUpper"); 227 this.extraParamInPredicate = dobj.param("extraIn"); 228 // property 229 this.extraProperty = dobj.get(extraPropertyName); 230 // comparison operations 231 this.extraEqual = extraProperty.equal(extraParamEqualPredicate); 232 this.extraIsNull = extraProperty.isNull(); 233 this.extraIsNotNull = extraProperty.isNotNull(); 234 this.extraGreaterThan = extraProperty.greaterThan(extraParamLowerPredicate); 235 this.extraGreaterEqual = extraProperty.greaterEqual(extraParamLowerPredicate); 236 this.extraLessThan = extraProperty.lessThan(extraParamUpperPredicate); 237 this.extraLessEqual = extraProperty.lessEqual(extraParamUpperPredicate); 238 this.extraBetween = extraProperty.between(extraParamLowerPredicate, extraParamUpperPredicate); 239 this.extraGreaterThanAndLessThan = extraLessThan.and(extraGreaterThan); 240 this.extraGreaterEqualAndLessThan = extraLessThan.and(extraGreaterEqual); 241 this.extraGreaterThanAndLessEqual = extraLessEqual.and(extraGreaterThan); 242 this.extraGreaterEqualAndLessEqual = extraLessEqual.and(extraGreaterEqual); 243 this.equalOrEqual = equal.or(extraEqual); 244 this.extraIn = extraProperty.in(extraParamInPredicate); 245 this.equalOrIn = equal.or(extraIn); 246 this.inAndIn = in.and(extraIn); 247 this.inAndBetween = in.and(extraBetween); 248 this.betweenAndIn = between.and(extraIn); 249 } createQuery(Session session)250 public void createQuery(Session session) { 251 query = session.createQuery(dobj); 252 } setParameterEqual(Object parameter)253 public void setParameterEqual(Object parameter) { 254 query.setParameter("equal", parameter); 255 } setParameterLower(Object parameter)256 public void setParameterLower(Object parameter) { 257 query.setParameter("lower", parameter); 258 } setParameterUpper(Object parameter)259 public void setParameterUpper(Object parameter) { 260 query.setParameter("upper", parameter); 261 } setParameterIn(Object parameter)262 public void setParameterIn(Object parameter) { 263 query.setParameter("in", parameter); 264 } setExpectedResultIds(int... expecteds)265 public void setExpectedResultIds(int... expecteds) { 266 for (int expected:expecteds) { 267 expectedSet.add(expected); 268 expectedList.add(expected); 269 } 270 } setExtraParameterEqual(Object parameter)271 public void setExtraParameterEqual(Object parameter) { 272 query.setParameter("extraEqual", parameter); 273 } setExtraParameterLower(Object parameter)274 public void setExtraParameterLower(Object parameter) { 275 query.setParameter("extraLower", parameter); 276 } setExtraParameterUpper(Object parameter)277 public void setExtraParameterUpper(Object parameter) { 278 query.setParameter("extraUpper", parameter); 279 } 280 setExtraParameterIn(Object parameter)281 public void setExtraParameterIn(Object parameter) { 282 query.setParameter("extraIn", parameter); 283 } 284 285 @SuppressWarnings("unchecked") checkResults(String theQuery)286 public void checkResults(String theQuery) { 287 if (limit != null) { 288 if (skip != null) { 289 query.setLimits(skip, limit); 290 } else { 291 query.setLimits(0, limit); 292 } 293 } 294 if (ordering != null) { 295 query.setOrdering(ordering, orderingFields); 296 } 297 Set<Integer> actualSet = new HashSet<Integer>(); 298 List<Integer> actualList = new ArrayList<Integer>(); 299 resultList = (List<IdBase>) query.getResultList(); 300 for (IdBase result: resultList) { 301 printResultInstance(result); 302 actualSet.add(result.getId()); 303 actualList.add(result.getId()); 304 } 305 errorIfNotEqual("Wrong index used for " + theQuery + " query: ", 306 expectedIndex, query.explain().get("IndexUsed")); 307 if (ordering != null) { 308 // must check ordering not just values 309 errorIfNotEqual("Wrong ids returned from ordered " + ordering + " " + theQuery + " query: ", 310 expectedList, actualList); 311 } else { 312 errorIfNotEqual("Wrong ids returned from " + theQuery + " query: ", 313 expectedSet, actualSet); 314 } 315 } 316 checkDeletePersistentAll(String where, int expectedNumberOfDeletedInstances)317 public void checkDeletePersistentAll(String where, int expectedNumberOfDeletedInstances) { 318 if (limit != null) { 319 if (skip != null) { 320 query.setLimits(skip, limit); 321 } else { 322 query.setLimits(0, limit); 323 } 324 } 325 int result = query.deletePersistentAll(); 326 errorIfNotEqual("Wrong index used for " + where + " delete query: ", 327 expectedIndex, query.explain().get("IndexUsed")); 328 errorIfNotEqual("Wrong number of instances deleted for " + where, 329 expectedNumberOfDeletedInstances, result); 330 } 331 } 332 333 /** This interface is for extra predicates. When the method is invoked, the 334 * QueryHolder has not been created, so this callback is executed to 335 * provide an extra query predicate after the holder is created. 336 */ 337 public interface PredicateProvider { getPredicate(QueryHolder holder)338 public Predicate getPredicate(QueryHolder holder); 339 } 340 341 PredicateProvider extraEqualPredicateProvider = 342 new PredicateProvider() { 343 public Predicate getPredicate(QueryHolder holder) { 344 return holder.extraEqual; 345 } 346 public String toString() { 347 return " equal"; 348 } 349 }; 350 351 PredicateProvider extraNotEqualPredicateProvider = 352 new PredicateProvider() { 353 public Predicate getPredicate(QueryHolder holder) { 354 return holder.extraEqual.not(); 355 } 356 public String toString() { 357 return " not equal"; 358 } 359 }; 360 361 PredicateProvider extraBetweenPredicateProvider = 362 new PredicateProvider() { 363 public Predicate getPredicate(QueryHolder holder) { 364 return holder.extraBetween; 365 } 366 public String toString() { 367 return " between"; 368 } 369 }; 370 371 PredicateProvider extraInPredicateProvider = 372 new PredicateProvider() { 373 public Predicate getPredicate(QueryHolder holder) { 374 return holder.extraIn; 375 } 376 public String toString() { 377 return " in"; 378 } 379 }; 380 381 PredicateProvider extraIsNullPredicateProvider = 382 new PredicateProvider() { 383 public Predicate getPredicate(QueryHolder holder) { 384 return holder.extraIsNull; 385 } 386 public String toString() { 387 return " isNull"; 388 } 389 }; 390 391 PredicateProvider extraIsNotNullPredicateProvider = 392 new PredicateProvider() { 393 public Predicate getPredicate(QueryHolder holder) { 394 return holder.extraIsNotNull; 395 } 396 public String toString() { 397 return " isNotNull"; 398 } 399 }; 400 401 /** Print the result instance. Override this in a subclass if needed. 402 * 403 * @param instance the instance to print if needed 404 */ printResultInstance(IdBase instance)405 protected void printResultInstance(IdBase instance) { 406 } 407 noWhereQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)408 public void noWhereQuery(String propertyName, String expectedIndex, 409 Object parameterValue, int... expected) { 410 tx.begin(); 411 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 412 // specify no where clause 413 // create the query 414 holder.createQuery(session); 415 // set the parameter value 416 holder.setParameterEqual(parameterValue); 417 // get the results 418 holder.setExpectedResultIds(expected); 419 holder.checkResults(propertyName + " noWhere"); 420 tx.commit(); 421 } 422 equalQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)423 public void equalQuery(String propertyName, String expectedIndex, 424 Object parameterValue, int... expected) { 425 tx.begin(); 426 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 427 // specify the where clause 428 holder.dobj.where(holder.equal); 429 // create the query 430 holder.createQuery(session); 431 // set the parameter value 432 holder.setParameterEqual(parameterValue); 433 // get the results 434 holder.setExpectedResultIds(expected); 435 holder.checkResults(propertyName + " equal"); 436 tx.commit(); 437 } 438 isNullQuery(String propertyName, String expectedIndex, int... expected)439 public void isNullQuery(String propertyName, String expectedIndex, int... expected) { 440 tx.begin(); 441 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 442 // specify the where clause 443 holder.dobj.where(holder.isNull); 444 // create the query 445 holder.createQuery(session); 446 // get the results 447 holder.setExpectedResultIds(expected); 448 holder.checkResults(propertyName + " isNull"); 449 tx.commit(); 450 } 451 isNotNullQuery(String propertyName, String expectedIndex, int... expected)452 public void isNotNullQuery(String propertyName, String expectedIndex, int... expected) { 453 tx.begin(); 454 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 455 // specify the where clause 456 holder.dobj.where(holder.isNotNull); 457 // create the query 458 holder.createQuery(session); 459 // get the results 460 holder.setExpectedResultIds(expected); 461 holder.checkResults(propertyName + " isNotNull"); 462 tx.commit(); 463 } 464 likeQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)465 public void likeQuery(String propertyName, String expectedIndex, 466 Object parameterValue, int... expected) { 467 tx.begin(); 468 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 469 // specify the where clause 470 holder.dobj.where(holder.like); 471 // create the query 472 holder.createQuery(session); 473 // set the parameter value 474 holder.setParameterEqual(parameterValue); 475 // get the results 476 holder.setExpectedResultIds(expected); 477 holder.checkResults(propertyName + " like"); 478 tx.commit(); 479 } 480 deleteEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int expected)481 public void deleteEqualQuery(String propertyName, String expectedIndex, 482 Object parameterValue, int expected) { 483 if (!autotransaction) { 484 tx.begin(); 485 } 486 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 487 // specify the where clause 488 holder.dobj.where(holder.equal); 489 // create the query 490 holder.createQuery(session); 491 // set the parameter value 492 holder.setParameterEqual(parameterValue); 493 // get the results 494 holder.checkDeletePersistentAll(propertyName + " delete equal", expected); 495 if (!autotransaction) { 496 tx.commit(); 497 } 498 } 499 equalOrEqualQuery(String propertyName, Object parameterValue1, String extraPropertyName, Object parameterValue2, String expectedIndex, int... expected)500 public void equalOrEqualQuery(String propertyName, Object parameterValue1, 501 String extraPropertyName, Object parameterValue2, 502 String expectedIndex, int... expected) { 503 tx.begin(); 504 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName); 505 // specify the where clause 506 holder.dobj.where(holder.equalOrEqual); 507 // create the query 508 holder.createQuery(session); 509 // set the parameter value 510 holder.setParameterEqual(parameterValue1); 511 holder.setExtraParameterEqual(parameterValue2); 512 // get the results 513 holder.setExpectedResultIds(expected); 514 holder.checkResults(propertyName + " equal or equal"); 515 tx.commit(); 516 } 517 equalOrInQuery(String propertyName, Object parameterValue1, String extraPropertyName, Object parameterValue2, String expectedIndex, int... expected)518 public void equalOrInQuery(String propertyName, Object parameterValue1, 519 String extraPropertyName, Object parameterValue2, 520 String expectedIndex, int... expected) { 521 tx.begin(); 522 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName); 523 // specify the where clause 524 holder.dobj.where(holder.equalOrIn); 525 // create the query 526 holder.createQuery(session); 527 // set the parameter value 528 holder.setParameterEqual(parameterValue1); 529 holder.setExtraParameterIn(parameterValue2); 530 // get the results 531 holder.setExpectedResultIds(expected); 532 holder.checkResults(propertyName + " equal or in"); 533 tx.commit(); 534 } 535 inQuery(String propertyName, Object parameterValue1, String expectedIndex, int... expected)536 public void inQuery(String propertyName, Object parameterValue1, 537 String expectedIndex, int... expected) { 538 inQuery("", propertyName, parameterValue1, expectedIndex, expected); 539 } 540 inQuery(String extraInfo, String propertyName, Object parameterValue1, String expectedIndex, int... expected)541 public void inQuery(String extraInfo, String propertyName, Object parameterValue1, 542 String expectedIndex, int... expected) { 543 tx.begin(); 544 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 545 // specify the where clause 546 holder.dobj.where(holder.in); 547 // create the query 548 holder.createQuery(session); 549 // set the parameter value 550 holder.setParameterIn(parameterValue1); 551 // get the results 552 holder.setExpectedResultIds(expected); 553 holder.checkResults(extraInfo + propertyName + " in"); 554 tx.commit(); 555 } 556 inAndInQuery(String propertyName, Object parameterValue1, String extraPropertyName, Object parameterValue2, String expectedIndex, int... expected)557 public void inAndInQuery(String propertyName, Object parameterValue1, 558 String extraPropertyName, Object parameterValue2, 559 String expectedIndex, int... expected) { 560 tx.begin(); 561 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName); 562 // specify the where clause 563 holder.dobj.where(holder.inAndIn); 564 // create the query 565 holder.createQuery(session); 566 // set the parameter value 567 holder.setParameterIn(parameterValue1); 568 holder.setExtraParameterIn(parameterValue2); 569 // get the results 570 holder.setExpectedResultIds(expected); 571 holder.checkResults(propertyName + " in and " + extraPropertyName + " in"); 572 tx.commit(); 573 } 574 inAndBetweenQuery(String propertyName, Object parameterValue1, String extraPropertyName, Object parameterValue2, Object parameterValue3, String expectedIndex, int...expected)575 public void inAndBetweenQuery(String propertyName, Object parameterValue1, 576 String extraPropertyName, Object parameterValue2, Object parameterValue3, 577 String expectedIndex, int...expected) { 578 tx.begin(); 579 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName); 580 // specify the where clause 581 holder.dobj.where(holder.inAndBetween); 582 // create the query 583 holder.createQuery(session); 584 // set the parameter value 585 holder.setParameterIn(parameterValue1); 586 holder.setExtraParameterLower(parameterValue2); 587 holder.setExtraParameterUpper(parameterValue3); 588 // get the results 589 holder.setExpectedResultIds(expected); 590 holder.checkResults(propertyName + " in and " + extraPropertyName + " between"); 591 tx.commit(); 592 } 593 betweenAndInQuery(String propertyName, Object parameterValue1, Object parameterValue2, String extraPropertyName, Object parameterValue3, String expectedIndex, int... expected)594 public void betweenAndInQuery(String propertyName, Object parameterValue1, Object parameterValue2, 595 String extraPropertyName, Object parameterValue3, 596 String expectedIndex, int... expected) { 597 tx.begin(); 598 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, extraPropertyName); 599 // specify the where clause 600 holder.dobj.where(holder.betweenAndIn); 601 // create the query 602 holder.createQuery(session); 603 // set the parameter value 604 holder.setParameterLower(parameterValue1); 605 holder.setParameterUpper(parameterValue2); 606 holder.setExtraParameterIn(parameterValue3); 607 // get the results 608 holder.setExpectedResultIds(expected); 609 holder.checkResults(propertyName + " between and " + extraPropertyName + " in"); 610 tx.commit(); 611 } 612 greaterThanQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)613 public void greaterThanQuery(String propertyName, String expectedIndex, 614 Object parameterValue, int... expected) { 615 616 tx.begin(); 617 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 618 // set the where clause into the query 619 holder.dobj.where(holder.greaterThan); 620 // create the query 621 holder.createQuery(session); 622 // set the parameter value 623 holder.setParameterLower(parameterValue); 624 // get the results 625 holder.setExpectedResultIds(expected); 626 holder.checkResults(propertyName + " greaterThan"); 627 tx.commit(); 628 } 629 greaterEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)630 public void greaterEqualQuery(String propertyName, String expectedIndex, 631 Object parameterValue, int... expected) { 632 633 tx.begin(); 634 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 635 // set the where clause into the query 636 holder.dobj.where(holder.greaterEqual); 637 // create the query 638 holder.createQuery(session); 639 // set the parameter value 640 holder.setParameterLower(parameterValue); 641 // get the results 642 holder.setExpectedResultIds(expected); 643 holder.checkResults(propertyName + " greaterEqual"); 644 tx.commit(); 645 } 646 lessThanQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)647 public void lessThanQuery(String propertyName, String expectedIndex, 648 Object parameterValue, int... expected) { 649 650 tx.begin(); 651 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 652 // set the where clause into the query 653 holder.dobj.where(holder.lessThan); 654 // create the query 655 holder.createQuery(session); 656 // set the parameter value 657 holder.setParameterUpper(parameterValue); 658 // get the results 659 holder.setExpectedResultIds(expected); 660 holder.checkResults(propertyName + " lessThan"); 661 tx.commit(); 662 } 663 lessEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)664 public void lessEqualQuery(String propertyName, String expectedIndex, 665 Object parameterValue, int... expected) { 666 667 tx.begin(); 668 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 669 // set the where clause into the query 670 holder.dobj.where(holder.lessEqual); 671 // create the query 672 holder.createQuery(session); 673 // set the parameter value 674 holder.setParameterUpper(parameterValue); 675 // get the results 676 holder.setExpectedResultIds(expected); 677 holder.checkResults(propertyName + " lessEqual"); 678 tx.commit(); 679 } 680 betweenQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)681 public void betweenQuery(String propertyName, String expectedIndex, 682 Object parameterLowerValue, Object parameterUpperValue, 683 int... expected) { 684 685 tx.begin(); 686 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 687 // set the where clause into the query 688 holder.dobj.where(holder.between); 689 // create the query 690 holder.createQuery(session); 691 // set the parameter value 692 holder.setParameterUpper(parameterUpperValue); 693 holder.setParameterLower(parameterLowerValue); 694 // get the results 695 holder.setExpectedResultIds(expected); 696 holder.checkResults(propertyName + " between"); 697 tx.commit(); 698 } 699 greaterThanAndLessThanQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)700 public void greaterThanAndLessThanQuery(String propertyName, String expectedIndex, 701 Object parameterLowerValue, Object parameterUpperValue, 702 int... expected) { 703 704 tx.begin(); 705 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 706 // set the where clause into the query 707 holder.dobj.where(holder.greaterThanAndLessThan); 708 // create the query 709 holder.createQuery(session); 710 // set the parameter value 711 holder.setParameterUpper(parameterUpperValue); 712 holder.setParameterLower(parameterLowerValue); 713 // get the results 714 holder.setExpectedResultIds(expected); 715 holder.checkResults(propertyName + " lessThanAndGreaterThan"); 716 tx.commit(); 717 } 718 greaterThanAndLikeQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)719 public void greaterThanAndLikeQuery(String propertyName, String expectedIndex, 720 Object parameterLowerValue, Object parameterUpperValue, 721 int... expected) { 722 723 tx.begin(); 724 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 725 // set the where clause into the query 726 holder.dobj.where(holder.greaterThanAndLike); 727 // create the query 728 holder.createQuery(session); 729 // set the parameter value 730 holder.setParameterUpper(parameterUpperValue); 731 holder.setParameterLower(parameterLowerValue); 732 // get the results 733 holder.setExpectedResultIds(expected); 734 holder.checkResults(propertyName + " greaterThanAndLike"); 735 tx.commit(); 736 } 737 deleteGreaterThanAndLessThanQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int expected)738 public void deleteGreaterThanAndLessThanQuery(String propertyName, String expectedIndex, 739 Object parameterLowerValue, Object parameterUpperValue, 740 int expected) { 741 if (!autotransaction) { 742 tx.begin(); 743 } 744 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 745 // set the where clause into the query 746 holder.dobj.where(holder.greaterThanAndLessThan); 747 // create the query 748 holder.createQuery(session); 749 // set the parameter value 750 holder.setParameterUpper(parameterUpperValue); 751 holder.setParameterLower(parameterLowerValue); 752 // get the results 753 holder.checkDeletePersistentAll(propertyName + " delete lessThanAndGreaterThan", expected); 754 if (!autotransaction) { 755 tx.commit(); 756 } 757 } 758 greaterEqualAndLessThanQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)759 public void greaterEqualAndLessThanQuery(String propertyName, String expectedIndex, 760 Object parameterLowerValue, Object parameterUpperValue, 761 int... expected) { 762 763 tx.begin(); 764 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 765 // set the where clause into the query 766 holder.dobj.where(holder.greaterEqualAndLessThan); 767 // create the query 768 holder.createQuery(session); 769 // set the parameter value 770 holder.setParameterUpper(parameterUpperValue); 771 holder.setParameterLower(parameterLowerValue); 772 // get the results 773 holder.setExpectedResultIds(expected); 774 holder.checkResults(propertyName + " lessThanAndGreaterEqual"); 775 tx.commit(); 776 } 777 greaterThanAndLessEqualQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)778 public void greaterThanAndLessEqualQuery(String propertyName, String expectedIndex, 779 Object parameterLowerValue, Object parameterUpperValue, 780 int... expected) { 781 782 tx.begin(); 783 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 784 // set the where clause into the query 785 holder.dobj.where(holder.greaterThanAndLessEqual); 786 // create the query 787 holder.createQuery(session); 788 // set the parameter value 789 holder.setParameterUpper(parameterUpperValue); 790 holder.setParameterLower(parameterLowerValue); 791 // get the results 792 holder.setExpectedResultIds(expected); 793 holder.checkResults(propertyName + " lessEqualAndGreaterThan"); 794 tx.commit(); 795 } 796 greaterEqualAndLessEqualQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)797 public void greaterEqualAndLessEqualQuery(String propertyName, String expectedIndex, 798 Object parameterLowerValue, Object parameterUpperValue, 799 int... expected) { 800 801 tx.begin(); 802 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 803 // set the where clause into the query 804 holder.dobj.where(holder.greaterEqualAndLessEqual); 805 // create the query 806 holder.createQuery(session); 807 // set the parameter value 808 holder.setParameterUpper(parameterUpperValue); 809 holder.setParameterLower(parameterLowerValue); 810 // get the results 811 holder.setExpectedResultIds(expected); 812 holder.checkResults(propertyName + " lessEqualAndGreaterEqual"); 813 tx.commit(); 814 } 815 greaterEqualAndLikeQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)816 public void greaterEqualAndLikeQuery(String propertyName, String expectedIndex, 817 Object parameterLowerValue, Object parameterUpperValue, 818 int... expected) { 819 820 tx.begin(); 821 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 822 // set the where clause into the query 823 holder.dobj.where(holder.greaterEqualAndLike); 824 // create the query 825 holder.createQuery(session); 826 // set the parameter value 827 holder.setParameterUpper(parameterUpperValue); 828 holder.setParameterLower(parameterLowerValue); 829 // get the results 830 holder.setExpectedResultIds(expected); 831 holder.checkResults(propertyName + " greaterEqualAndLike"); 832 tx.commit(); 833 } 834 equalAnd1ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, String expectedIndex, int... expected)835 public void equalAnd1ExtraQuery(String propertyName, Object parameterValue, 836 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 837 String expectedIndex, int... expected) { 838 tx.begin(); 839 holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 840 extraPropertyName); 841 // specify the where clause 842 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 843 holder.dobj.where(holder.equal.and(extraPredicate)); 844 // create the query 845 holder.createQuery(session); 846 // set the parameter value 847 holder.setParameterEqual(parameterValue); 848 holder.setParameterLower(parameterValue); 849 holder.setParameterUpper(parameterValue); 850 holder.setExtraParameterEqual(extraParameterValue); 851 holder.setExtraParameterLower(extraParameterValue); 852 holder.setExtraParameterUpper(extraParameterValue); 853 // get the results 854 holder.setExpectedResultIds(expected); 855 holder.checkResults(propertyName + " equal and " + extraPredicate); 856 tx.commit(); 857 } 858 greaterThanAnd1ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, String expectedIndex, int... expected)859 public void greaterThanAnd1ExtraQuery(String propertyName, Object parameterValue, 860 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 861 String expectedIndex, int... expected) { 862 tx.begin(); 863 holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 864 extraPropertyName); 865 // specify the where clause 866 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 867 holder.dobj.where(holder.greaterThan.and(extraPredicate)); 868 // create the query 869 holder.createQuery(session); 870 // set the parameter value 871 holder.setParameterEqual(parameterValue); 872 holder.setParameterLower(parameterValue); 873 holder.setParameterUpper(parameterValue); 874 holder.setExtraParameterEqual(extraParameterValue); 875 holder.setExtraParameterLower(extraParameterValue); 876 holder.setExtraParameterUpper(extraParameterValue); 877 // get the results 878 holder.setExpectedResultIds(expected); 879 holder.checkResults(propertyName + " greater than and " + extraPropertyName + extraPredicateProvider.toString()); 880 tx.commit(); 881 } 882 greaterEqualAnd1ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, String expectedIndex, int... expected)883 public void greaterEqualAnd1ExtraQuery(String propertyName, Object parameterValue, 884 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 885 String expectedIndex, int... expected) { 886 tx.begin(); 887 holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 888 extraPropertyName); 889 // specify the where clause 890 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 891 holder.dobj.where(holder.greaterEqual.and(extraPredicate)); 892 // create the query 893 holder.createQuery(session); 894 // set the parameter value 895 holder.setParameterEqual(parameterValue); 896 holder.setParameterLower(parameterValue); 897 holder.setParameterUpper(parameterValue); 898 holder.setExtraParameterEqual(extraParameterValue); 899 holder.setExtraParameterLower(extraParameterValue); 900 holder.setExtraParameterUpper(extraParameterValue); 901 // get the results 902 holder.setExpectedResultIds(expected); 903 holder.checkResults(propertyName + " greater equal and " + extraPropertyName + extraPredicateProvider.toString()); 904 tx.commit(); 905 } 906 lessThanAnd1ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, String expectedIndex, int... expected)907 public void lessThanAnd1ExtraQuery(String propertyName, Object parameterValue, 908 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 909 String expectedIndex, int... expected) { 910 tx.begin(); 911 holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 912 extraPropertyName); 913 // specify the where clause 914 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 915 holder.dobj.where(holder.lessThan.and(extraPredicate)); 916 // create the query 917 holder.createQuery(session); 918 // set the parameter value 919 holder.setParameterEqual(parameterValue); 920 holder.setParameterLower(parameterValue); 921 holder.setParameterUpper(parameterValue); 922 holder.setExtraParameterEqual(extraParameterValue); 923 holder.setExtraParameterLower(extraParameterValue); 924 holder.setExtraParameterUpper(extraParameterValue); 925 // get the results 926 holder.setExpectedResultIds(expected); 927 holder.checkResults(propertyName + " less than and " + extraPropertyName + extraPredicateProvider.toString()); 928 tx.commit(); 929 } 930 lessEqualAnd1ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, String expectedIndex, int... expected)931 public void lessEqualAnd1ExtraQuery(String propertyName, Object parameterValue, 932 String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue, 933 String expectedIndex, int... expected) { 934 tx.begin(); 935 holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 936 extraPropertyName); 937 // specify the where clause 938 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 939 holder.dobj.where(holder.lessEqual.and(extraPredicate)); 940 // create the query 941 holder.createQuery(session); 942 // set the parameter value 943 holder.setParameterEqual(parameterValue); 944 holder.setParameterLower(parameterValue); 945 holder.setParameterUpper(parameterValue); 946 holder.setExtraParameterEqual(extraParameterValue); 947 holder.setExtraParameterLower(extraParameterValue); 948 holder.setExtraParameterUpper(extraParameterValue); 949 // get the results 950 holder.setExpectedResultIds(expected); 951 holder.checkResults(propertyName + " less equal and " + extraPropertyName + extraPredicateProvider.toString()); 952 tx.commit(); 953 } 954 equalAnd2ExtraQuery(String propertyName, Object parameterValue, String extraPropertyName, PredicateProvider extraPredicateProvider, Object extraParameterValue1, Object extraParameterValue2, String expectedIndex, int... expected)955 public void equalAnd2ExtraQuery(String propertyName, Object parameterValue, 956 String extraPropertyName, PredicateProvider extraPredicateProvider, 957 Object extraParameterValue1, Object extraParameterValue2, 958 String expectedIndex, int... expected) { 959 tx.begin(); 960 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex, 961 extraPropertyName); 962 // specify the where clause 963 Predicate extraPredicate = extraPredicateProvider.getPredicate(holder); 964 holder.dobj.where(holder.equal.and(extraPredicate)); 965 // create the query 966 holder.createQuery(session); 967 // set the parameter value 968 holder.setParameterEqual(parameterValue); 969 holder.setParameterLower(parameterValue); 970 holder.setParameterUpper(parameterValue); 971 holder.setExtraParameterEqual(extraParameterValue1); 972 holder.setExtraParameterLower(extraParameterValue1); 973 holder.setExtraParameterUpper(extraParameterValue2); 974 // get the results 975 holder.setExpectedResultIds(expected); 976 holder.checkResults(propertyName + " equal and " + extraPredicate); 977 tx.commit(); 978 } 979 notEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)980 public void notEqualQuery(String propertyName, String expectedIndex, 981 Object parameterValue, int... expected) { 982 tx.begin(); 983 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 984 // specify the where clause 985 holder.dobj.where(holder.notEqual); 986 // create the query 987 holder.createQuery(session); 988 // set the parameter value 989 holder.setParameterEqual(parameterValue); 990 // get the results 991 holder.setExpectedResultIds(expected); 992 holder.checkResults(propertyName + " not equal"); 993 tx.commit(); 994 } 995 notNotEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)996 public void notNotEqualQuery(String propertyName, String expectedIndex, 997 Object parameterValue, int... expected) { 998 tx.begin(); 999 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1000 // specify the where clause 1001 holder.dobj.where(holder.notEqual.not()); 1002 // create the query 1003 holder.createQuery(session); 1004 // set the parameter value 1005 holder.setParameterEqual(parameterValue); 1006 // get the results 1007 holder.setExpectedResultIds(expected); 1008 holder.checkResults(propertyName + " not not equal"); 1009 tx.commit(); 1010 } 1011 notNotNotEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)1012 public void notNotNotEqualQuery(String propertyName, String expectedIndex, 1013 Object parameterValue, int... expected) { 1014 tx.begin(); 1015 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1016 // specify the where clause 1017 holder.dobj.where(holder.dobj.not(holder.notEqual.not())); 1018 // create the query 1019 holder.createQuery(session); 1020 // set the parameter value 1021 holder.setParameterEqual(parameterValue); 1022 // get the results 1023 holder.setExpectedResultIds(expected); 1024 holder.checkResults(propertyName + " not not not equal"); 1025 tx.commit(); 1026 } 1027 notGreaterThanQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)1028 public void notGreaterThanQuery(String propertyName, String expectedIndex, 1029 Object parameterValue, int... expected) { 1030 1031 tx.begin(); 1032 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1033 // set the where clause into the query 1034 holder.dobj.where(holder.notGreaterThan); 1035 // create the query 1036 holder.createQuery(session); 1037 // set the parameter value 1038 holder.setParameterLower(parameterValue); 1039 // get the results 1040 holder.setExpectedResultIds(expected); 1041 holder.checkResults(propertyName + " not greaterThan"); 1042 tx.commit(); 1043 } 1044 notGreaterEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)1045 public void notGreaterEqualQuery(String propertyName, String expectedIndex, 1046 Object parameterValue, int... expected) { 1047 1048 tx.begin(); 1049 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1050 // set the where clause into the query 1051 holder.dobj.where(holder.notGreaterEqual); 1052 // create the query 1053 holder.createQuery(session); 1054 // set the parameter value 1055 holder.setParameterLower(parameterValue); 1056 // get the results 1057 holder.setExpectedResultIds(expected); 1058 holder.checkResults(propertyName + " not greaterEqual"); 1059 tx.commit(); 1060 } 1061 notLessThanQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)1062 public void notLessThanQuery(String propertyName, String expectedIndex, 1063 Object parameterValue, int... expected) { 1064 1065 tx.begin(); 1066 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1067 // set the where clause into the query 1068 holder.dobj.where(holder.notLessThan); 1069 // create the query 1070 holder.createQuery(session); 1071 // set the parameter value 1072 holder.setParameterUpper(parameterValue); 1073 // get the results 1074 holder.setExpectedResultIds(expected); 1075 holder.checkResults(propertyName + " not lessThan"); 1076 tx.commit(); 1077 } 1078 notLessEqualQuery(String propertyName, String expectedIndex, Object parameterValue, int... expected)1079 public void notLessEqualQuery(String propertyName, String expectedIndex, 1080 Object parameterValue, int... expected) { 1081 1082 tx.begin(); 1083 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1084 // set the where clause into the query 1085 holder.dobj.where(holder.notLessEqual); 1086 // create the query 1087 holder.createQuery(session); 1088 // set the parameter value 1089 holder.setParameterUpper(parameterValue); 1090 // get the results 1091 holder.setExpectedResultIds(expected); 1092 holder.checkResults(propertyName + " not lessEqual"); 1093 tx.commit(); 1094 } 1095 notBetweenQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)1096 public void notBetweenQuery(String propertyName, String expectedIndex, 1097 Object parameterLowerValue, Object parameterUpperValue, 1098 int... expected) { 1099 1100 tx.begin(); 1101 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1102 // set the where clause into the query 1103 holder.dobj.where(holder.notBetween); 1104 // create the query 1105 holder.createQuery(session); 1106 // set the parameter value 1107 holder.setParameterUpper(parameterUpperValue); 1108 holder.setParameterLower(parameterLowerValue); 1109 // get the results 1110 holder.setExpectedResultIds(expected); 1111 holder.checkResults(propertyName + " not between"); 1112 tx.commit(); 1113 } 1114 greaterThanAndNotGreaterThanQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)1115 public void greaterThanAndNotGreaterThanQuery(String propertyName, String expectedIndex, 1116 Object parameterLowerValue, Object parameterUpperValue, 1117 int... expected) { 1118 1119 tx.begin(); 1120 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1121 // set the where clause into the query 1122 holder.dobj.where(holder.greaterThanAndNotGreaterThan); 1123 // create the query 1124 holder.createQuery(session); 1125 // set the parameter value 1126 holder.setParameterUpper(parameterUpperValue); 1127 holder.setParameterLower(parameterLowerValue); 1128 // get the results 1129 holder.setExpectedResultIds(expected); 1130 holder.checkResults(propertyName + " greaterThanAndNotGreaterThan"); 1131 tx.commit(); 1132 } 1133 greaterEqualAndNotGreaterThanQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)1134 public void greaterEqualAndNotGreaterThanQuery(String propertyName, String expectedIndex, 1135 Object parameterLowerValue, Object parameterUpperValue, 1136 int... expected) { 1137 1138 tx.begin(); 1139 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1140 // set the where clause into the query 1141 holder.dobj.where(holder.greaterEqualAndNotGreaterThan); 1142 // create the query 1143 holder.createQuery(session); 1144 // set the parameter value 1145 holder.setParameterUpper(parameterUpperValue); 1146 holder.setParameterLower(parameterLowerValue); 1147 // get the results 1148 holder.setExpectedResultIds(expected); 1149 holder.checkResults(propertyName + " greaterEqualAndNotGreaterThan"); 1150 tx.commit(); 1151 } 1152 greaterThanAndNotGreaterEqualQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)1153 public void greaterThanAndNotGreaterEqualQuery(String propertyName, String expectedIndex, 1154 Object parameterLowerValue, Object parameterUpperValue, 1155 int... expected) { 1156 1157 tx.begin(); 1158 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1159 // set the where clause into the query 1160 holder.dobj.where(holder.greaterThanAndNotGreaterEqual); 1161 // create the query 1162 holder.createQuery(session); 1163 // set the parameter value 1164 holder.setParameterUpper(parameterUpperValue); 1165 holder.setParameterLower(parameterLowerValue); 1166 // get the results 1167 holder.setExpectedResultIds(expected); 1168 holder.checkResults(propertyName + " greaterThanAndNotGreaterEqual"); 1169 tx.commit(); 1170 } 1171 greaterEqualAndNotGreaterEqualQuery(String propertyName, String expectedIndex, Object parameterLowerValue, Object parameterUpperValue, int... expected)1172 public void greaterEqualAndNotGreaterEqualQuery(String propertyName, String expectedIndex, 1173 Object parameterLowerValue, Object parameterUpperValue, 1174 int... expected) { 1175 1176 tx.begin(); 1177 QueryHolder holder = new QueryHolder(getInstanceType(), propertyName, expectedIndex); 1178 // set the where clause into the query 1179 holder.dobj.where(holder.greaterEqualAndNotGreaterEqual); 1180 // create the query 1181 holder.createQuery(session); 1182 // set the parameter value 1183 holder.setParameterUpper(parameterUpperValue); 1184 holder.setParameterLower(parameterLowerValue); 1185 // get the results 1186 holder.setExpectedResultIds(expected); 1187 holder.checkResults(propertyName + " greaterEqualAndNotGreaterEqual"); 1188 tx.commit(); 1189 } 1190 1191 } 1192