Package ejava.examples.orm.map
Class ManyManyMapTest
- java.lang.Object
-
- ejava.examples.orm.rel.DemoBase
-
- ejava.examples.orm.map.ManyManyMapTest
-
public class ManyManyMapTest extends DemoBase
This class demonstrates a Many-to-Many relationship represented as a Map in the owning entity. There are two types of entities represented in these tests. In each case, the foreign key is placed in a link table.- ManyManyInverseEntity to/from OneManyOwningEntity - One end owns the relationship and the other end is the inverse. The inverse side has a reference to the owning side, but the application code (DAO or business logic) is responsible for maintaining the inverse side's reference.
- ManyManyOwningEntity to ManyManyEntity - since all foreign key information about the relationship is stored in a link/join table, this is almost identical to the case described above except that the non-owning side has no knowledge of the relationship. All this means is that the application code has no responsibility to update the inverse side.
-
-
Constructor Summary
Constructors Constructor Description ManyManyMapTest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
cleanup()
This method will cleanup the database of our ManyToMany entities.protected void
postcleanup()
protected void
precleanup()
void
testManyToManyInverseMap()
This method tests the case where one entity owns the many-to-many, bi-directional relationship and the other side forms the inverse side.void
XtestManyToManyMap()
This method tests the a simpler version of the owning/inverse case.-
Methods inherited from class ejava.examples.orm.rel.DemoBase
setUpBase, setUpDownShared, tearDownBase, tearDownBaseClass
-
-
-
-
Method Detail
-
precleanup
protected void precleanup() throws Exception
- Overrides:
precleanup
in classDemoBase
- Throws:
Exception
-
postcleanup
protected void postcleanup() throws Exception
- Overrides:
postcleanup
in classDemoBase
- Throws:
Exception
-
cleanup
protected void cleanup() throws Exception
This method will cleanup the database of our ManyToMany entities. We start with the owning entities, since they own the link/join tables with the foreign keys. Once the associations have been deleted, all inverse and oblivious entities can be safely removed.- Throws:
Exception
-
testManyToManyInverseMap
public void testManyToManyInverseMap()
This method tests the case where one entity owns the many-to-many, bi-directional relationship and the other side forms the inverse side. If we model the Java form of the relationship without defining a
-
XtestManyToManyMap
public void XtestManyToManyMap()
This method tests the a simpler version of the owning/inverse case. This case only has an owning side. The final schema ends up looking like the following...create table ORMMAP_MANYMANY_ENTITY ( name varchar(255) not null, primary key (name) ); create table ORMMAP_MANYMANY_OWNENTITY ( name varchar(255) not null, primary key (name) ); create table ORMMAP_MANYMANY_OWNENTITY_ORMMAP_MANYMANY_ENTITY ( ORMMAP_MANYMANY_OWNENTITY_name varchar(255) not null, ownedEntities_name varchar(255) not null, primary key (ORMMAP_MANYMANY_OWNENTITY_name, ownedEntities_name) );
-
-