Package ejava.examples.orm.rel
Class RelationshipOwnershipTest
- java.lang.Object
-
- ejava.examples.orm.rel.DemoBase
-
- ejava.examples.orm.rel.RelationshipOwnershipTest
-
public class RelationshipOwnershipTest extends DemoBase
This test case provides a demo of a ManyToMany relationship. This, of course, also uses a Join (or link) table.
-
-
Field Summary
Fields Modifier and Type Field Description private long
applicantId
private long
borrowerId
-
Constructor Summary
Constructors Constructor Description RelationshipOwnershipTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
setUp()
This setUp method creates a few objects that we'll use to test a few relations.void
tearDown()
This method makes sure there are no relationships left over after testvoid
testOnetoOneInverse()
This method will verify that setting only the inverse side of a OnetoOne relationship does not update the database.void
testOnetoOneOwnership()
This method will verify that setting only the owning side of a OnetoOne relationship does update the database, but leaves the cache in an inconsistent state until refreshed.-
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 few objects that we'll use to test a few relations.- Throws:
Exception
-
tearDown
public void tearDown() throws Exception
This method makes sure there are no relationships left over after test- Throws:
Exception
-
testOnetoOneInverse
public void testOnetoOneInverse()
This method will verify that setting only the inverse side of a OnetoOne relationship does not update the database. In this particular case the Application table contains the foreign key to the Borrower, so an update of only the Borrower object does not get reflected in the DB when the transaction commits.
-
testOnetoOneOwnership
public void testOnetoOneOwnership()
This method will verify that setting only the owning side of a OnetoOne relationship does update the database, but leaves the cache in an inconsistent state until refreshed. In this particular case the Application table contains the foreign key to the Borrower. A change to Applicant gets written to DB, but not automatically reflected in Borrower until manually set of refreshed.
-
-