use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class CAY_115IT method testDistinctClobFetchWithToManyJoin.
@Test
public void testDistinctClobFetchWithToManyJoin() throws Exception {
if (!accessStackAdapter.supportsLobInsertsAsStrings()) {
return;
}
createDistinctClobFetchWithToManyJoin();
Expression qual = ExpressionFactory.exp("details.name like 'cd%'");
SelectQuery query = new SelectQuery(ClobMaster.class, qual);
List<?> result = context.performQuery(query);
assertEquals(3, result.size());
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class CAY_194IT method testQualifyOnToMany.
@Test
public void testQualifyOnToMany() {
ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
ox.setName("ox");
ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
o1.setName("o1");
ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
o2.setName("o2");
o2.setToParent(o1);
context.commitChanges();
Expression qualifier = ExpressionFactory.matchExp("children", o2);
List<?> parents = context.performQuery(new SelectQuery(ReflexiveAndToOne.class, qualifier));
assertEquals(1, parents.size());
assertSame(o1, parents.get(0));
qualifier = ExpressionFactory.matchExp("children", o1);
parents = context.performQuery(new SelectQuery(ReflexiveAndToOne.class, qualifier));
assertEquals(0, parents.size());
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class CAY_194IT method testQualifyOnToOne.
@Test
public void testQualifyOnToOne() {
ReflexiveAndToOne ox = context.newObject(ReflexiveAndToOne.class);
ox.setName("ox");
ReflexiveAndToOne o1 = context.newObject(ReflexiveAndToOne.class);
o1.setName("o1");
ReflexiveAndToOne o2 = context.newObject(ReflexiveAndToOne.class);
o2.setName("o2");
o2.setToParent(o1);
context.commitChanges();
Expression qualifier = ExpressionFactory.matchExp("toParent", o1);
List<?> children = context.performQuery(new SelectQuery(ReflexiveAndToOne.class, qualifier));
assertEquals(1, children.size());
assertSame(o2, children.get(0));
o2.setToParent(null);
context.commitChanges();
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class SimpleIdIncrementalFaultListIT method testNewObject.
@Test
public void testNewObject() throws Exception {
createArtistsDataSet();
Artist newArtist = context.newObject(Artist.class);
newArtist.setArtistName("x");
context.commitChanges();
SelectQuery<Artist> q = new SelectQuery<Artist>(Artist.class);
q.setPageSize(6);
q.addOrdering(Artist.ARTIST_NAME.asc());
SimpleIdIncrementalFaultList<?> list = new SimpleIdIncrementalFaultList<Object>(context, q, 10000);
assertSame(newArtist, list.get(25));
}
use of org.apache.cayenne.query.SelectQuery in project cayenne by apache.
the class SimpleIdIncrementalFaultListIT method testLastIndexOf.
@Test
public void testLastIndexOf() throws Exception {
SimpleIdIncrementalFaultList<?> list = prepareList(6);
Expression qual = ExpressionFactory.matchExp("artistName", "artist20");
SelectQuery query = new SelectQuery(Artist.class, qual);
List<?> artists = list.dataContext.performQuery(query);
assertEquals(1, artists.size());
Artist row = (Artist) artists.get(0);
assertEquals(19, list.lastIndexOf(row));
assertEquals(-1, list.lastIndexOf(list.dataContext.newObject("Artist")));
}
Aggregations