I have table A and table B that are mapped to classes A and B respectively (you can assume the most simplistic mappings for now) that have identifiers A_ID and B_ID. They have a many-many relationship that is given an ID, AB_ID in an AB_Relationship table..
There is a third class C that is mapped to class C with identifier C_ID. C has a many-many relationship with A kept in the CA_Relationship table with ID CA_ID. I want to be able to pick what B's I can attach to this relationship by using the AB_Relationship table, but not necessarily all B's for the A related to C. So now I have introduced yet another relationship CA to B (Where the only B's available are those with an A-B relationship). I don't know where to begin on this last part.
Hibernate version:
3.2.4
Mapping documents:
A mapping
...
<class name="A" table="A">
<id name="A_ID" column="A_ID">
<generator class="sequence"/>
</id>
<idbag name="myBs" table="AB_Rltn" cascade="save-update">
<collection-id type="java.lang.Integer" column="AB_ID">
<generator class="sequence"/>
</collection-id>
<key column="A_ID" not-null="true"/>
<many-to-many column="B_ID" class="B"/>
</idbag>
</class>
...
B mapping
...
<class name="B" table="B">
<id name="B_ID" column="B_ID">
<generator class="sequence"/>
</id>
</class>
C mapping with relationship to A, but do not know how to put the CA to B relationship or if it would even go in this file
...
<class name="C" table="C">
<id name="C_ID" column="C_ID">
<generator class="sequence"/>
</id>
<idbag name="myAs" table="CA_Rltn" cascade="save-update">
<collection-id type="java.lang.Integer" column="CA_ID">
<generator class="sequence"/>
</collection-id>
<key column="C_ID" not-null="true"/>
<many-to-many column="A_ID" class="A"/>
</idbag>
</class>
Name and version of the database you are using:
Oracle 10g
|