Class OneToManyTest


  • public class OneToManyTest
    extends DemoBase
    This test case provides a demo of OneToMany and ManyToOne relationships. In this type of relationship, the foreign key is either in the many side's table or a link table.
    • Field Detail

      • borrowerId

        private long borrowerId
    • Constructor Detail

      • OneToManyTest

        public OneToManyTest()
    • Method Detail

      • setUp

        public void setUp()
                   throws Exception
        This setUp method creates a Borrower to be used during the test methods.
        Throws:
        Exception
      • testManyOneBiDirectional

        public void testManyOneBiDirectional()
        This provides a basic demonstration of setting up a One/Many relationship. Take special note that because the entities of regular POJOs and we no longer have CMR from EJB2.1, we must manually update the in-memory references on both sides. However, it is only the setting() and persisting of the owning side of the relation that updates any foreign key relationships.
      • testRemove

        public void testRemove()
        This provides a basic demonstration of removing entities from a One/Many relationship. Note that we have to update the java fields on both sides of the bi-directional relationship.