-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Joining table mapping HOWTO
PostPosted: Tue Jul 22, 2008 5:04 pm 
Newbie

Joined: Tue Jul 22, 2008 4:55 pm
Posts: 3
Hi,

Lets say I have Users abd Products tables. UserOrders table is a joining table and has UserId and ProductId columns.

In my User class I have a list of ordered products. How do I define mapping from Users to Products table through UserOrders table?

Please give me an example of mapping xml.

Thanks,

Sharas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 23, 2008 3:12 am 
Expert
Expert

Joined: Thu Dec 14, 2006 5:57 am
Posts: 1185
Location: Zurich, Switzerland
Try this

Code:
<set name="Products" lazy="false" table="UserOrders">
   <key column="productid"/>
   <many-to-many class="Order" column="orderid"/>
</set>


and have a look at the documentation for many-to-many associations.

http://www.hibernate.org/hib_docs/nhibernate/1.2/reference/en/html/collections.html#collections-ofvalues

_________________
--Wolfgang


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.