use of org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1 in project cayenne by apache.
the class DataContextEntityWithMeaningfulPKIT method testMeaningfulIntPK.
@Test
public void testMeaningfulIntPK() {
MeaningfulPKTest1 obj1 = context.newObject(MeaningfulPKTest1.class);
obj1.setIntAttribute(10);
obj1.setPkAttribute(1);
MeaningfulPKTest1 obj2 = context.newObject(MeaningfulPKTest1.class);
obj2.setIntAttribute(20);
obj2.setPkAttribute(2);
context.commitChanges();
ObjectContext context = runtime.newContext();
List<MeaningfulPKTest1> objects = ObjectSelect.query(MeaningfulPKTest1.class).select(context);
assertEquals(2, objects.size());
assertEquals(1, obj1.getPkAttribute());
assertEquals(2, obj2.getPkAttribute());
}
use of org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1 in project cayenne by apache.
the class DataContextEntityWithMeaningfulPKIT method testToManyRelationshipWithMeaningfulPK2.
@Test
public void testToManyRelationshipWithMeaningfulPK2() {
MeaningfulPKTest1 obj = context.newObject(MeaningfulPKTest1.class);
obj.setPkAttribute(1000);
obj.setDescr("aaa-aaa");
context.commitChanges();
// must be able to set reverse relationship
MeaningfulPKDep dep = context.newObject(MeaningfulPKDep.class);
dep.setToMeaningfulPK(obj);
context.commitChanges();
}
Aggregations