use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testNUMERIC2.
@Test
public void testNUMERIC2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
BigDecimal numericValue = new BigDecimal("578438.57843");
test.setNumericColumn(numericValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
BigDecimal columnValue = testRead.getNumericColumn();
assertNotNull(columnValue);
assertEquals(BigDecimal.class, columnValue.getClass());
assertEquals(numericValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class ReturnTypesMappingIT method testTINYINT2.
@Test
public void testTINYINT2() throws Exception {
ReturnTypesMap1 test = context.newObject(ReturnTypesMap1.class);
Byte tinyintValue = 89;
test.setTinyintColumn(tinyintValue);
context.commitChanges();
SelectQuery q = new SelectQuery(ReturnTypesMap1.class);
ReturnTypesMap1 testRead = (ReturnTypesMap1) context.performQuery(q).get(0);
Byte columnValue = testRead.getTinyintColumn();
assertNotNull(columnValue);
assertEquals(Byte.class, columnValue.getClass());
assertEquals(tinyintValue, columnValue);
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class QueryCacheIT method testLocalCache.
@Test
public void testLocalCache() {
Artist a = context1.newObject(Artist.class);
a.setArtistName("artist");
context1.commitChanges();
SelectQuery q = new SelectQuery(Artist.class);
q.setCacheStrategy(QueryCacheStrategy.LOCAL_CACHE);
List<Artist> result1 = context1.performQuery(q);
List<Artist> result2 = context2.performQuery(q);
assertNotSame(result1.get(0).getObjectContext(), result2.get(0).getObjectContext());
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class DataContextPrefetchQualifierOverlapIT method testToManyDisjointOverlappingQualifierWithInnerJoin.
@Test
public void testToManyDisjointOverlappingQualifierWithInnerJoin() throws Exception {
createTwoArtistsThreePaintingsDataSet();
SelectQuery query = new SelectQuery(Artist.class);
query.andQualifier(ExpressionFactory.likeExp("paintingArray.paintingTitle", "AB%"));
query.addPrefetch(Artist.PAINTING_ARRAY.disjoint());
List<Artist> result = context.performQuery(query);
assertEquals(1, result.size());
Artist a = result.get(0);
assertEquals(3, a.getPaintingArray().size());
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class DataContextPrefetchQualifierOverlapIT method testToManyJointOverlappingQualifierWithOuterJoin.
@Test
public void testToManyJointOverlappingQualifierWithOuterJoin() throws Exception {
createTwoArtistsThreePaintingsDataSet();
SelectQuery query = new SelectQuery(Artist.class);
query.andQualifier(ExpressionFactory.likeExp("paintingArray+.paintingTitle", "AB%"));
query.addPrefetch(Artist.PAINTING_ARRAY.joint());
query.orQualifier(ExpressionFactory.likeExp("artistName", "A%"));
query.addOrdering(Artist.ARTIST_NAME.asc());
List<Artist> result = context.performQuery(query);
assertEquals(2, result.size());
Artist a = result.get(0);
assertEquals(3, a.getPaintingArray().size());
Artist a1 = result.get(1);
assertEquals(0, a1.getPaintingArray().size());
}
Aggregations