|
31 | 31 | import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKDep; |
32 | 32 | import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1; |
33 | 33 | import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPk; |
| 34 | +import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPkBigint; |
34 | 35 | import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPkDep2; |
35 | 36 | import org.apache.cayenne.testdo.meaningful_pk.MeaningfulPkTest2; |
36 | 37 | import org.apache.cayenne.unit.di.runtime.CayenneProjects; |
|
39 | 40 | import org.junit.Ignore; |
40 | 41 | import org.junit.Test; |
41 | 42 |
|
| 43 | +import java.math.BigInteger; |
42 | 44 | import java.util.List; |
43 | 45 |
|
44 | 46 | import static org.junit.Assert.*; |
@@ -269,4 +271,60 @@ public void test_MeaningfulPkWithFkUpdate() { |
269 | 271 | obj.setPkAttribute(1002); |
270 | 272 | context.commitChanges(); |
271 | 273 | } |
| 274 | + |
| 275 | + @Test |
| 276 | + public void testPaginatedQuery() { |
| 277 | + MeaningfulPk pkObj = context.newObject(MeaningfulPk.class); |
| 278 | + pkObj.setPk("123"); |
| 279 | + context.commitChanges(); |
| 280 | + |
| 281 | + MeaningfulPk pkObj2 = context.newObject(MeaningfulPk.class); |
| 282 | + pkObj2.setPk("124"); |
| 283 | + context.commitChanges(); |
| 284 | + |
| 285 | + MeaningfulPk pkObj3 = context.newObject(MeaningfulPk.class); |
| 286 | + pkObj3.setPk("125"); |
| 287 | + context.commitChanges(); |
| 288 | + |
| 289 | + ObjectContext cleanContext = runtime.newContext(); |
| 290 | + |
| 291 | + List<MeaningfulPk> select = ObjectSelect.query(MeaningfulPk.class) |
| 292 | + .orderBy(MeaningfulPk.PK.asc()) |
| 293 | + .pageSize(1) |
| 294 | + .select(cleanContext); |
| 295 | + |
| 296 | + assertEquals(3, select.size()); |
| 297 | + for(MeaningfulPk pk : select) { |
| 298 | + assertNotNull(pk.getPk()); |
| 299 | + assertTrue(pk.getPk().startsWith("12")); |
| 300 | + } |
| 301 | + } |
| 302 | + |
| 303 | + @Test |
| 304 | + public void testPaginatedQueryBigInteger() { |
| 305 | + MeaningfulPkBigint pkObj = context.newObject(MeaningfulPkBigint.class); |
| 306 | + pkObj.setPk(BigInteger.valueOf(123)); |
| 307 | + context.commitChanges(); |
| 308 | + |
| 309 | + MeaningfulPkBigint pkObj2 = context.newObject(MeaningfulPkBigint.class); |
| 310 | + pkObj2.setPk(BigInteger.valueOf(124)); |
| 311 | + context.commitChanges(); |
| 312 | + |
| 313 | + MeaningfulPkBigint pkObj3 = context.newObject(MeaningfulPkBigint.class); |
| 314 | + pkObj3.setPk(BigInteger.valueOf(125)); |
| 315 | + context.commitChanges(); |
| 316 | + |
| 317 | + ObjectContext cleanContext = runtime.newContext(); |
| 318 | + |
| 319 | + List<MeaningfulPkBigint> select = ObjectSelect.query(MeaningfulPkBigint.class) |
| 320 | + .orderBy(MeaningfulPk.PK.asc()) |
| 321 | + .pageSize(1) |
| 322 | + .select(cleanContext); |
| 323 | + |
| 324 | + assertEquals(3, select.size()); |
| 325 | + for(MeaningfulPkBigint pk : select) { |
| 326 | + assertNotNull(pk.getPk()); |
| 327 | + assertTrue(pk.getPk().compareTo(BigInteger.valueOf(120)) > 0); |
| 328 | + } |
| 329 | + } |
272 | 330 | } |
0 commit comments