use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextCompoundRelIT method testFetchQualifyingToOne.
@Test
public void testFetchQualifyingToOne() {
CompoundPkTestEntity master = context.newObject(CompoundPkTestEntity.class);
CompoundPkTestEntity master1 = context.newObject(CompoundPkTestEntity.class);
CompoundFkTestEntity detail = context.newObject(CompoundFkTestEntity.class);
CompoundFkTestEntity detail1 = context.newObject(CompoundFkTestEntity.class);
master.addToCompoundFkArray(detail);
master1.addToCompoundFkArray(detail1);
master.setName("m1");
master.setKey1("key11");
master.setKey2("key21");
master1.setName("m2");
master1.setKey1("key12");
master1.setKey2("key22");
detail.setName("d1");
detail1.setName("d2");
context.commitChanges();
context.invalidateObjects(master, master1, detail, detail1);
List<CompoundFkTestEntity> objs = ObjectSelect.query(CompoundFkTestEntity.class).where(CompoundFkTestEntity.TO_COMPOUND_PK.eq(master)).select(context1);
assertEquals(1, objs.size());
assertEquals("d1", objs.get(0).getName());
}
use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextCompoundRelIT method testFetchQualifyingToMany.
@Test
public void testFetchQualifyingToMany() {
CompoundPkTestEntity master = context.newObject(CompoundPkTestEntity.class);
CompoundPkTestEntity master1 = context.newObject(CompoundPkTestEntity.class);
CompoundFkTestEntity detail = context.newObject(CompoundFkTestEntity.class);
CompoundFkTestEntity detail1 = context.newObject(CompoundFkTestEntity.class);
master.addToCompoundFkArray(detail);
master1.addToCompoundFkArray(detail1);
master.setName("m1");
master.setKey1("key11");
master.setKey2("key21");
master1.setName("m2");
master1.setKey1("key12");
master1.setKey2("key22");
detail.setName("d1");
detail1.setName("d2");
context.commitChanges();
context.invalidateObjects(master, master1, detail, detail1);
List<CompoundPkTestEntity> objs = ObjectSelect.query(CompoundPkTestEntity.class).where(CompoundPkTestEntity.COMPOUND_FK_ARRAY.contains(detail1)).select(context1);
assertEquals(1, objs.size());
assertEquals("m2", objs.get(0).getName());
}
use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextEJBQLQueryCompoundIT method testSelectFromWhereNoMatchOnMultiColumnObject.
@Test
public void testSelectFromWhereNoMatchOnMultiColumnObject() throws Exception {
createTwoCompoundPKTwoFK();
Map<String, String> key1 = new HashMap<>();
key1.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "b1");
key1.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "b2");
CompoundPkTestEntity a = Cayenne.objectForPK(context, CompoundPkTestEntity.class, key1);
String ejbql = "select e from CompoundFkTestEntity e WHERE e.toCompoundPk <> :param";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("param", a);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
CompoundFkTestEntity o1 = (CompoundFkTestEntity) ps.get(0);
assertEquals(33001, Cayenne.intPKForObject(o1));
}
use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextEJBQLQueryCompoundIT method testSelectFromWhereMatchOnMultiColumnObjectReverse.
@Test
public void testSelectFromWhereMatchOnMultiColumnObjectReverse() throws Exception {
if (!accessStackAdapter.supportsReverseComparison()) {
return;
}
createTwoCompoundPKTwoFK();
Map<String, String> key1 = new HashMap<>();
key1.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "b1");
key1.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "b2");
CompoundPkTestEntity a = Cayenne.objectForPK(context, CompoundPkTestEntity.class, key1);
String ejbql = "select e from CompoundFkTestEntity e WHERE :param = e.toCompoundPk";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("param", a);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
CompoundFkTestEntity o1 = (CompoundFkTestEntity) ps.get(0);
assertEquals(33002, Cayenne.intPKForObject(o1));
}
use of org.apache.cayenne.testdo.compound.CompoundPkTestEntity in project cayenne by apache.
the class DataContextEJBQLQueryCompoundIT method testSelectFromWhereMatchOnMultiColumnObject.
@Test
public void testSelectFromWhereMatchOnMultiColumnObject() throws Exception {
createTwoCompoundPKTwoFK();
Map<String, String> key1 = new HashMap<>();
key1.put(CompoundPkTestEntity.KEY1_PK_COLUMN, "b1");
key1.put(CompoundPkTestEntity.KEY2_PK_COLUMN, "b2");
CompoundPkTestEntity a = Cayenne.objectForPK(context, CompoundPkTestEntity.class, key1);
String ejbql = "select e from CompoundFkTestEntity e WHERE e.toCompoundPk = :param";
EJBQLQuery query = new EJBQLQuery(ejbql);
query.setParameter("param", a);
List<?> ps = context.performQuery(query);
assertEquals(1, ps.size());
CompoundFkTestEntity o1 = (CompoundFkTestEntity) ps.get(0);
assertEquals(33002, Cayenne.intPKForObject(o1));
}
Aggregations