Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Advanced
Nov 12, 2007

Using the <idbag> Element in Hibernate

Hibernate's <idbag> facility allows you to map many-to-many associations and collections of values to a single table with a surrogate key. The following code shows an example of <idbag> mapping:

<idbag name="cars" table="CARS">
    <collection-id column="car_id" type="long">
        <generator class="sequence"/>
    </collection-id>
    <key column="car_I"/>
    <many-to-many column="car_II" class="Car" outer-join="true"/>
</idbag>
Done!

Leonard Anghel
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap