Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Java Databases > Hibernate M:M m...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3728 of 3747
Post > Topic >>

Hibernate M:M mapping plus extra data in intermediary table

by Spendius <spendius@[EMAIL PROTECTED] > Apr 24, 2008 at 06:08 AM

Hello,

I'm asking a question already asked a few years ago:
http://groups.google.be/group/comp.lang.java.databases/browse_frm/thread/c3a1045674b6b65f/c3aa99a30b22c8e6?hl=nl&lnk=gst&q=%22many-to-many%22&utoken=DT02DTsAAAAYHYTsDrEdq7-NnfRgl-Nk4GfRPBFGhDGPHFrvVDkRvgz1eTbjLK36WL5svdAfvL03TRB4SbQHh5KfXKICx3ka

When your middle table (that which relates your 2 tables
through a many-to-many relationship) contains more than
the A_ID and B_ID columns but also -for ex.- DATE columns
etc.- is there a way to deal with this extra info with some
more config in your .hbm.xml files or do you really need a
supplementary class to handle this data ?

When you have no more than the 2 ID columns to deal with,
the following mappings are enough:
<set name="events" table="PERSON_EVENT">
<key column="PERSON_ID"/>
<many-to-many column="EVENT_ID" class="Event"/>
</set>
in a file and
<set name="participants" table="PERSON_EVENT" inverse="true">
<key column="EVENT_ID"/>
<many-to-many column="PERSON_ID" class="Person"/>
</set>
in the other .hbm.xml file... And no specific class for the
PERSON_EVENT database table is required - but when this
table contains other columns, is there no way but to create
another class to play with this extra columns ?

In advance, thanks.
Regards,
Spendius




 2 Posts in Topic:
Hibernate M:M mapping plus extra data in intermediary table
Spendius <spendius@[EM  2008-04-24 06:08:53 
Re: Hibernate M:M mapping plus extra data in intermediary table
Axel Hallez <Axel.Hall  2008-04-25 10:33:30 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed May 14 22:26:15 CDT 2008.