-->
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: Which is the right way to insert records in a medial table?
PostPosted: Sat Jul 28, 2007 3:11 pm 
Newbie

Joined: Sun Oct 01, 2006 6:33 am
Posts: 8
Hello.
I wondered which is the right way to insert records in a medial table, that is, a table for many-to-many associations.

It exists in the collection mappings.
In the java-code it is just a Set, that get be fetched from one of the objects.

If we want to add a record to this medial table (for example users_favorites, that is - links 'users' and 'favorites' for a many-to-many association)?

Code:
Set favorites = user.getFavorites();
favorites.add(newFavorite); // Adds the new entry?
user.setFavorites(favorites);
session.saveOrUpdate(user);


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jul 28, 2007 5:17 pm 
Newbie

Joined: Sat Jul 14, 2007 6:02 pm
Posts: 8
have a look here
http://www.hibernate.org/hib_docs/v3/re ... child.html

It has an example of a parent child relationship.


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.