Package ejava.examples.orm.rel
Class OneToManyTest
- java.lang.Object
-
- ejava.examples.orm.rel.DemoBase
-
- ejava.examples.orm.rel.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.
-
-
Constructor Summary
Constructors Constructor Description OneToManyTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setUp()
This setUp method creates a Borrower to be used during the test methods.void
testManyOneBiDirectional()
This provides a basic demonstration of setting up a One/Many relationship.void
testRemove()
This provides a basic demonstration of removing entities from a One/Many relationship.-
Methods inherited from class ejava.examples.orm.rel.DemoBase
postcleanup, precleanup, setUpBase, setUpDownShared, tearDownBase, tearDownBaseClass
-
-
-
-
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.
-
-