-->
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: Adding a new instance to a already existing collection
PostPosted: Fri Jun 11, 2004 4:58 am 
Beginner
Beginner

Joined: Thu May 13, 2004 5:51 am
Posts: 28
I have a many-to-many relationship between two tables A and B. I need to update A by setting a new B to the collection of Bs in A.

Set Bs = A.getB();
Bs.add(b)
session.flush();

My Bs collection is lazy. My problem is, when I add a new B to the collection, I am reading the entire collection and then adding to it! :( I dont want to be doing that, since I just need to save another B and link it up in A-B linking table. What should I be doing to avoid this?

Also every update, delete is accompanied by a prior select. I do not have any version/optimistic-locking/select before update set. What could be the reason for this?

--


Top
 Profile  
 
 Post subject: Re: Adding a new instance to a already existing collection
PostPosted: Mon Jun 14, 2004 7:38 pm 
Regular
Regular

Joined: Sat Feb 21, 2004 8:54 pm
Posts: 60
Location: Lakewood, California
mmesh wrote:
I have a many-to-many relationship ...
My Bs collection is lazy. My problem is, when I add a new B to the collection, I am reading the entire collection and then adding to it! ...


it may be working as designed. someone posted the links below to answer a related question. iirc, you can prevent the lazy load by just pointing the child to the parent, but then hibernate may become out of sync with the db.

http://www.hibernate.org/155.html

http://www.hibernate.org/hib_docs/refer ... child.html

thanks

_________________
<http://tayek.com/>, co-chair <http://www.ocjug.org/>, actively
seeking telecommuting work. hate spam?
<https://www1.ietf.org/mailman/listinfo/asrg>


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.