19 package testsuite.clusterj;
21 import testsuite.clusterj.model.Employee;
22 import com.mysql.clusterj.query.QueryBuilder;
23 import com.mysql.clusterj.query.QueryDomainType;
24 import com.mysql.clusterj.query.Predicate;
25 import com.mysql.clusterj.query.PredicateOperand;
27 import com.mysql.clusterj.Query;
29 import java.util.HashSet;
30 import java.util.List;
37 createSessionFactory();
40 createEmployeeInstances(10);
45 }
catch (Throwable t) {
58 primaryKeyBetweenQuery();
59 primaryKeyEqualQuery();
60 primaryKeyGreaterEqualQuery();
61 primaryKeyGreaterThanQuery();
62 primaryKeyLessEqualQuery();
63 primaryKeyLessThanQuery();
66 public void primaryKeyEqualQuery() {
86 query.setParameter(
"id", 8);
88 List<Employee> results = query.getResultList();
90 consistencyCheck(results);
92 errorIfNotEqual(
"Wrong employee id returned from query: ",
93 8, results.get(0).getId());
97 public void primaryKeyGreaterThanQuery() {
106 PredicateOperand param = dobj.param(
"id");
108 PredicateOperand column = dobj.get(
"id");
110 Predicate compare = column.greaterThan(param);
117 query.setParameter(
"id", 6);
121 consistencyCheck(results);
129 actual.add(emp.getId());
131 errorIfNotEqual(
"Wrong employee ids returned from query: ",
136 public void primaryKeyGreaterEqualQuery() {
145 PredicateOperand param = dobj.param(
"id");
147 PredicateOperand column = dobj.get(
"id");
149 Predicate compare = column.greaterEqual(param);
156 query.setParameter(
"id", 7);
160 consistencyCheck(results);
168 actual.add(emp.getId());
170 errorIfNotEqual(
"Wrong employee ids returned from query: ",
175 public void primaryKeyLessThanQuery() {
184 PredicateOperand param = dobj.param(
"id");
186 PredicateOperand column = dobj.get(
"id");
188 Predicate compare = column.lessThan(param);
195 query.setParameter(
"id", 3);
199 consistencyCheck(results);
207 actual.add(emp.getId());
209 errorIfNotEqual(
"Wrong employee ids returned from query: ",
214 public void primaryKeyLessEqualQuery() {
223 PredicateOperand param = dobj.param(
"id");
225 PredicateOperand column = dobj.get(
"id");
227 Predicate compare = column.lessEqual(param);
234 query.setParameter(
"id", 2);
238 consistencyCheck(results);
246 actual.add(emp.getId());
248 errorIfNotEqual(
"Wrong employee ids returned from query: ",
253 public void primaryKeyBetweenQuery() {
262 PredicateOperand lower = dobj.param(
"lower");
264 PredicateOperand upper = dobj.param(
"upper");
266 PredicateOperand column = dobj.get(
"id");
268 Predicate compare = column.between(lower, upper);
275 query.setParameter(
"lower", 5);
276 query.setParameter(
"upper", 7);
280 consistencyCheck(results);
288 actual.add(emp.getId());
290 errorIfNotEqual(
"Wrong employee ids returned from query: ",