Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.databases > #24 > unrolled thread
| Started by | "Spendius" <spendius@THRWHITE.remove-dii-this> |
|---|---|
| First post | 2011-04-27 15:21 +0000 |
| Last post | 2011-04-27 15:21 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.java.databases
Hibernate M:M mapping plu "Spendius" <spendius@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
Re: Hibernate M:M mapping "Axel Hallez" <axel.hallez@THRWHITE.remove-dii-this> - 2011-04-27 15:21 +0000
| From | "Spendius" <spendius@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:21 +0000 |
| Subject | Hibernate M:M mapping plu |
| Message-ID | <ffeba001-8b9d-4511-91c0-277dd497397e@x35g2000hsb.googlegroups.com> |
To: comp.lang.java.databases 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 --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [next] | [standalone]
| From | "Axel Hallez" <axel.hallez@THRWHITE.remove-dii-this> |
|---|---|
| Date | 2011-04-27 15:21 +0000 |
| Subject | Re: Hibernate M:M mapping |
| Message-ID | <furunm$77b$1@gaudi2.UGent.be> |
| In reply to | #24 |
To: comp.lang.java.databases Spendius wrote: > 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 ? If you don't wrap the extra attributes in a class, how would you be able to manage them? If a many-to-many relationship has extra attributes, this generally means that the relationship entries are entities in their own right. Now I guess that one could come up with some schema to avoid the definition of an extra class, but I can't imagine that this would be easier to deal with. Kind regards, Axel Hallez --- * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet! --- Synchronet 3.15a-Win32 NewsLink 1.92 Time Warp of the Future BBS - telnet://time.synchro.net:24
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.databases
csiph-web