use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.
the class CmrMappingTests method testEjbSelectWithCMR.
public void testEjbSelectWithCMR() throws Exception {
beginTransaction();
try {
final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
owningLocal.setOneInverseSide(inverseLocal);
completeTransaction();
owningLocal.testEJBSelect();
} catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
completeTransaction();
cleanDb();
}
}
use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.
the class CmrMappingTests method testOneToOneSetCMROnInverseSide.
public void testOneToOneSetCMROnInverseSide() throws Exception {
beginTransaction();
try {
final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
inverseLocal.setOneOwningSide(owningLocal);
completeTransaction();
validateOneToOneRelationship();
} catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
completeTransaction();
cleanDb();
}
}
use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.
the class CmrMappingTests method testOneToOneSetCMROnOwningSide.
public void testOneToOneSetCMROnOwningSide() throws Exception {
beginTransaction();
try {
final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
final OneOwningSideLocal owningLocal = createOneOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
owningLocal.setOneInverseSide(inverseLocal);
completeTransaction();
validateOneToOneRelationship();
} catch (final Throwable e) {
e.printStackTrace();
throw new TestFailureException(new AssertionFailedError("Received Exception " + e.getClass() + " : " + e.getMessage()));
} finally {
completeTransaction();
cleanDb();
}
}
use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.
the class CmrMappingTests method validateOneToManyRelationship.
private void validateOneToManyRelationship() throws NotSupportedException, SystemException, Exception, HeuristicMixedException, HeuristicRollbackException, RollbackException {
try {
final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
// verify one side has a set containing the many bean
final Set set = inverseLocal.getManyOwningSide();
Assert.assertEquals(1, set.size());
final ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next();
Assert.assertEquals(compoundPK_20_10, owningLocal.getPrimaryKey());
// verify the many bean has a back reference to the one
final OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide();
Assert.assertNotNull(oneInverseSide);
Assert.assertEquals(compoundPK_20_10_field1, oneInverseSide.getPrimaryKey());
completeTransaction();
} finally {
completeTransaction();
}
}
use of org.apache.openejb.test.entity.cmr.cmrmapping.OneInverseSideLocal in project tomee by apache.
the class CmrMappingTests method validateOneToOneRelationship.
private void validateOneToOneRelationship() throws Exception {
try {
final OneInverseSideLocal inverseLocal = findOneInverseSide(compoundPK_20_10_field1);
final OneOwningSideLocal oneOwningSide = inverseLocal.getOneOwningSide();
Assert.assertNotNull(oneOwningSide);
Assert.assertEquals(compoundPK_20_10, oneOwningSide.getPrimaryKey());
final OneInverseSideLocal inverseBackRef = oneOwningSide.getOneInverseSide();
Assert.assertNotNull(inverseBackRef);
Assert.assertEquals(compoundPK_20_10_field1, inverseBackRef.getPrimaryKey());
completeTransaction();
} finally {
completeTransaction();
}
}
Aggregations