Re: Hibernate M:M mapping plus extra data in intermediary table
- From: Axel Hallez <Axel.Hallez@xxxxxxxx>
- Date: Fri, 25 Apr 2008 10:33:30 +0200
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
.
- References:
- Hibernate M:M mapping plus extra data in intermediary table
- From: Spendius
- Hibernate M:M mapping plus extra data in intermediary table
- Prev by Date: A replica rolex watch is available in various designs and qualities with almost same quality measure and components as the original ones, which stand for class and elegance. Fake rolex watches provide as an alternative for the original Rolex watches. Rolex replica watches have a high degree of resemblance to the original ones and it is hard to note out the difference between the two. As the original ones, the replica rolex watch even uses the same mechanism which does not use battery. Swiss replica watches are the best manufactured fake rolex watches, and they look excellent, express style and class, and work great. Everyone aspires to own a great Rolex watch, but with a nice replica rolex watch, one can make the dream come true and that too without spending a huge amount of money. Swiss replica watches mimic the real thing into a degree of perfection. The quality of fake rolex watches i...
- Next by Date: Today imitation jewelry is getting popular, pirated CDs are mostly sold and replica industry is growing. The fact is that only a few people are able to afford it. There are only a handful of people for whom these extraordinary timepieces are manufactured. These are not produced on a mass scale. So, this idea of creating a fake item generated. Sometimes, it so happens that a Rolex replica looks more original than a real one. Many people buy these replica rolex watches.
- Previous by thread: Hibernate M:M mapping plus extra data in intermediary table
- Next by thread: specifying a database name in jdbc:jndi:ldap connection
- Index(es):