Package org.apache.openejb.test.entity.cmr.cmrmapping

Examples of org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal


    public void testOneToManySetCMROnOwningSideResetPK() throws Exception {
        beginTransaction();
        try {

            final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
            owningLocal.setOneInverseSide(inverseLocal);
// todo should fail when we have fk as part of pk
//            Assert.fail();
            completeTransaction();
        } catch (final TransactionRolledbackLocalException e) {
            if (!(e.getCause() instanceof IllegalStateException)) {
View Full Code Here


    public void testOneToManySetCMROnInverseSide() throws Exception {
        beginTransaction();
        try {

            final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
            inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
            completeTransaction();

            validateOneToManyRelationship();
        } catch (final Throwable e) {
View Full Code Here

    public void testOneToManySetCMROnInverseSideResetPK() throws Exception {
        beginTransaction();
        try {

            final OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            final ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
            inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
// todo should fail when we have fk as part of pk
//            Assert.fail();
            completeTransaction();
        } catch (final TransactionRolledbackLocalException e) {
View Full Code Here

        return home.findByPrimaryKey(id);
    }

    private ManyOwningSideLocal createManyOwningSide(final Integer id, final Integer field1) throws Exception {
        final ManyOwningSideLocalHome home = manyHome;
        final ManyOwningSideLocal manyOwningSideLocal = home.create(id, field1);
        manyCreated.add(id);
        return manyOwningSideLocal;
    }
View Full Code Here


            // 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 {
View Full Code Here

    public void testOneToManySetCMROnOwningSideResetPK() throws Exception {
        beginTransaction();
        try {

            OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
            owningLocal.setOneInverseSide(inverseLocal);
// todo should fail when we have fk as part of pk
//            Assert.fail();
            completeTransaction();
        } catch (TransactionRolledbackLocalException e) {
            if (!(e.getCause() instanceof IllegalStateException)) {
View Full Code Here

    public void testOneToManySetCMROnInverseSide() throws Exception {
        beginTransaction();
        try {

            OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_10, compoundPK_20_10_field1);
            inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
            completeTransaction();

            validateOneToManyRelationship();
        } catch (Throwable e) {
View Full Code Here

    public void testOneToManySetCMROnInverseSideResetPK() throws Exception {
        beginTransaction();
        try {

            OneInverseSideLocal inverseLocal = createOneInverseSide(compoundPK_20_10_field1);
            ManyOwningSideLocal owningLocal = createManyOwningSide(compoundPK_20_20, compoundPK_20_20_field1);
            inverseLocal.setManyOwningSide(Collections.singleton(owningLocal));
// todo should fail when we have fk as part of pk
//            Assert.fail();
            completeTransaction();
        } catch (TransactionRolledbackLocalException e) {
View Full Code Here

        return home.findByPrimaryKey(id);
    }

    private ManyOwningSideLocal createManyOwningSide(Integer id, Integer field1) throws Exception {
        ManyOwningSideLocalHome home = manyHome;
        ManyOwningSideLocal manyOwningSideLocal = home.create(id, field1);
        manyCreated.add(id);
        return manyOwningSideLocal;
    }
View Full Code Here


            // verify one side has a set containing the many bean
            Set set = inverseLocal.getManyOwningSide();
            Assert.assertEquals(1, set.size());
            ManyOwningSideLocal owningLocal = (ManyOwningSideLocal) set.iterator().next();
            Assert.assertEquals(compoundPK_20_10, owningLocal.getPrimaryKey());

            // verify the many bean has a back reference to the one
            OneInverseSideLocal oneInverseSide = owningLocal.getOneInverseSide();
            Assert.assertNotNull(oneInverseSide);
            Assert.assertEquals(compoundPK_20_10_field1, oneInverseSide.getPrimaryKey());

            completeTransaction();
        } finally {
View Full Code Here

TOP

Related Classes of org.apache.openejb.test.entity.cmr.cmrmapping.ManyOwningSideLocal

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.