use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1 in project cayenne by apache.
the class DataContextEJBQLFlattenedRelationshipsIT method testCollectionMemberOfThetaJoin.
@Test
public void testCollectionMemberOfThetaJoin() throws Exception {
createFt123();
String ejbql = "SELECT f FROM FlattenedTest3 f, FlattenedTest1 ft " + "WHERE f MEMBER OF ft.ft3Array AND ft = :ft";
FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 2);
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("ft", ft);
List<?> objects = context.performQuery(query);
assertEquals(2, objects.size());
Set<Object> ids = new HashSet<Object>();
Iterator<?> it = objects.iterator();
while (it.hasNext()) {
Object id = Cayenne.pkForObject((Persistent) it.next());
ids.add(id);
}
assertTrue(ids.contains(2));
assertTrue(ids.contains(3));
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1 in project cayenne by apache.
the class DataContextEJBQLFlattenedRelationshipsIT method testCollectionAsInnerJoin.
@Test
public void testCollectionAsInnerJoin() throws Exception {
createFt123();
// this query is equivalent to the previous INNER JOIN example
String ejbql = "SELECT OBJECT(ft) FROM FlattenedTest1 ft, IN(ft.ft3Array) f WHERE ft = :ft";
FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 1);
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("ft", ft);
List<?> objects = context.performQuery(query);
assertNotNull(objects);
assertFalse(objects.isEmpty());
assertEquals(1, objects.size());
Set<Object> ids = new HashSet<Object>();
Iterator<?> it = objects.iterator();
while (it.hasNext()) {
Object id = Cayenne.pkForObject((Persistent) it.next());
ids.add(id);
}
assertTrue(ids.contains(new Integer(1)));
}
use of org.apache.cayenne.testdo.relationships_flattened.FlattenedTest1 in project cayenne by apache.
the class DataContextEJBQLFlattenedRelationshipsIT method testCollectionIdentificationVariable.
@Test
public void testCollectionIdentificationVariable() throws Exception {
createFt123();
String ejbql = "SELECT ft.ft3Array FROM FlattenedTest1 ft WHERE ft = :ft";
FlattenedTest1 ft = Cayenne.objectForPK(context, FlattenedTest1.class, 2);
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("ft", ft);
List<?> objects = context.performQuery(query);
assertNotNull(objects);
assertFalse(objects.isEmpty());
assertEquals(2, objects.size());
Set<Object> ids = new HashSet<Object>();
Iterator<?> it = objects.iterator();
while (it.hasNext()) {
Object id = Cayenne.pkForObject((Persistent) it.next());
ids.add(id);
}
assertTrue(ids.contains(new Integer(2)));
assertTrue(ids.contains(new Integer(3)));
}
Aggregations