use of org.apache.cayenne.testdo.generated.GeneratedColumnDep in project cayenne by apache.
the class IdentityColumnsIT method testUnrelatedUpdate.
/**
* Tests CAY-422 bug.
*/
@Test
public void testUnrelatedUpdate() throws Exception {
GeneratedColumnTestEntity m = context.newObject(GeneratedColumnTestEntity.class);
m.setName("m");
GeneratedColumnDep d = context.newObject(GeneratedColumnDep.class);
d.setName("d");
d.setToMaster(m);
context.commitChanges();
context.invalidateObjects(m, d);
context.prepareForAccess(d, null, false);
// this line caused CAY-422 error
d.getToMaster();
d.setName("new name");
context.commitChanges();
}
use of org.apache.cayenne.testdo.generated.GeneratedColumnDep in project cayenne by apache.
the class IdentityColumnsIT method testUpdateDependentWithNewMaster.
@Test
public void testUpdateDependentWithNewMaster() throws Exception {
GeneratedColumnTestEntity master1 = context.newObject(GeneratedColumnTestEntity.class);
master1.setName("aaa");
GeneratedColumnDep dependent = context.newObject(GeneratedColumnDep.class);
dependent.setName("aaa");
dependent.setToMaster(master1);
context.commitChanges();
// change master
GeneratedColumnTestEntity master2 = context.newObject(GeneratedColumnTestEntity.class);
master2.setName("bbb");
// TESTING THIS
dependent.setToMaster(master2);
context.commitChanges();
int id1 = Cayenne.intPKForObject(master2);
assertTrue(id1 >= 0);
int id2 = Cayenne.intPKForObject(dependent);
assertTrue(id2 >= 0);
assertEquals(id1, id2);
context.invalidateObjects(master2, dependent);
assertNotNull(Cayenne.objectForPK(context, GeneratedColumnTestEntity.class, id1));
assertNotNull(Cayenne.objectForPK(context, GeneratedColumnDep.class, id2));
}
use of org.apache.cayenne.testdo.generated.GeneratedColumnDep in project cayenne by apache.
the class IdentityColumnsIT method testPropagateToDependent.
@Test
public void testPropagateToDependent() throws Exception {
GeneratedColumnTestEntity idObject = context.newObject(GeneratedColumnTestEntity.class);
idObject.setName("aaa");
GeneratedColumnDep dependent = idObject.getObjectContext().newObject(GeneratedColumnDep.class);
dependent.setName("aaa");
dependent.setToMaster(idObject);
context.commitChanges();
// this will throw an exception if id wasn't generated
int id1 = Cayenne.intPKForObject(idObject);
assertTrue(id1 >= 0);
int id2 = Cayenne.intPKForObject(dependent);
assertTrue(id2 >= 0);
assertEquals(id1, id2);
// refetch from DB
context.invalidateObjects(idObject, dependent);
assertNotNull(Cayenne.objectForPK(context, GeneratedColumnTestEntity.class, id1));
assertNotNull(Cayenne.objectForPK(context, GeneratedColumnDep.class, id2));
}
Aggregations