Hello,
I have the following problem. I have three tables.
A -------- C --------- B
A contains x amount of records B contains y amount of records C associates 1 record from A with B
I want to create a hibernate mapping that will make this clean and easy.
I have ClassA, ClassB, ClassC
I want it so a getter in ClassA returns ClassB via table C. I have achieved this with the following but it is not perfect
<set name="a" inverse="false" table="C"> <cache usage="read-write" region="StandardQueryCache" /> <key> <column name="A_ID" precision="22" scale="0" not-null="true" /> </key> <many-to-many entity-name="com.test.B"> <column name="B_ID" precision="22" scale="0" not-null="true" /> </many-to-many> </set>
<set name="b" inverse="false" table="C"> <cache usage="read-write" region="StandardQueryCache" /> <key> <column name="B_ID" precision="22" scale="0" not-null="true" /> </key> <many-to-many entity-name="com.test.A"> <column name="A_ID" precision="22" scale="0" not-null="true" /> </many-to-many> </set>
This works however since the relationship between A and B will ALWAYS be one-to-one, this is kind of a hack.
Any help on how to clean this up would be greatly appreciated.
Thanks,
Brad
|