Hello,
after searching the documentation and forum posts I am still stuck with
the question how to map a many-to-many relationship between two tables
with the relationship table having a primary key of its own and extra attributes:
Code:
T_MANY1 T_RELATION T_MANY2
MANY1_ID (PK) RELATION_ID (PK) MANY2_ID (PK)
FOO (ATTRIB) FK_TO_MANY1 (FK1) BAR (ATTRIB)
FK_TO_MANY2 (FK2)
STATUS (ATTRIB)
DATE (ATTRIB)
I've learned I could use the <idbag>-tag introduced in 6.13. of the hibernate reference with the many-to-many tag, but then, I can't figure out how to adress the extra fields STATUS and DATE.
Alternatively, trying to map the above with
Code:
...
<idbag>
...
<composite-element class=" ...>
<property name="status" .../>
<many-to-one .../>
</composite-element>
</idbag>
I do not understand wether I have to do this in the mappings of both outer tables and wonder which java classes to generate/write. Until now, I ended up with four classes mapping the above relation, leaving me with a feeling of doubt....
Could someone give me some insight or even better, provide an understandable example of two mapping files, please?
Thanks,
Markus