-->
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.  [ 3 posts ] 
Author Message
 Post subject: Joining table mapping HOWTO
PostPosted: Tue Jul 22, 2008 5:13 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 6:23 am 
Newbie

Joined: Wed Jul 23, 2008 5:29 am
Posts: 3
Location: Hong Kong
User get List of Products
http://www.hibernate.org/hib_docs/refer ... l-join-12m


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 3:23 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
So, it sounds like you're asking for simply an one to many mapping? Here's a tutorial on how Hibernate does it:

Tutorial: Mapping One to Many Associations with Hibernate and JPA

If you're using compound primary keys, here's another discussion you might want to look at:


http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=15usingcompoundprimarykeys

Good luck!

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.