-->
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.  [ 4 posts ] 
Author Message
 Post subject: em.merge very inefficient
PostPosted: Fri Feb 03, 2006 4:14 am 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
For an entity that has more than one collections:
For example,

Class Student {

@ManyToMany
List<Course> getCourses();

@OneToMany
List<Cat> getCats();

}

If I add a course to the student, and then em.merge(student). The following will happen: (from generated SQL)

1. delete all associations in the association table for courses, and insert all including for the new course.

2. delete all associations for Cat, and than add all. This is not necessary because I did not change cat collection.

Is this the way Hibernate does for merge? Is there a better? Ideally just insert one row into the association table for adding one course to the student.

Thanks for ideas.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:56 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Why are you using a bag semantic?

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 10:21 pm 
Senior
Senior

Joined: Tue Sep 13, 2005 2:01 am
Posts: 137
Thanks
what other options do I have?
I just use annotations such as @OneToMany.
Please advise.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Feb 10, 2006 7:13 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
http://www.hibernate.org/hib_docs/annotations/reference/en/html_single/#entity-mapping-association-collections

_________________
Emmanuel


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