Search in sources :

Example 6 with MeaningfulPKTest1

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());
}
Also used : MeaningfulPKTest1(org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1) ObjectContext(org.apache.cayenne.ObjectContext) Test(org.junit.Test)

Example 7 with MeaningfulPKTest1

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();
}
Also used : MeaningfulPKDep(org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKDep) MeaningfulPKTest1(org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1) Test(org.junit.Test)

Aggregations

MeaningfulPKTest1 (org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKTest1)7 Test (org.junit.Test)7 ObjectContext (org.apache.cayenne.ObjectContext)3 ObjectId (org.apache.cayenne.ObjectId)2 List (java.util.List)1 Map (java.util.Map)1 DataRow (org.apache.cayenne.DataRow)1 ObjectIdQuery (org.apache.cayenne.query.ObjectIdQuery)1 MeaningfulPKDep (org.apache.cayenne.testdo.meaningful_pk.MeaningfulPKDep)1