Class 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 Detail

      • borrowerId

        private long borrowerId
      • applicantId

        private long applicantId
    • Constructor Detail

      • RelationshipOwnershipTest

        public RelationshipOwnershipTest()
    • 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.