-->
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: .add reads all collection items
PostPosted: Mon Sep 29, 2003 6:17 am 
Newbie

Joined: Mon Sep 29, 2003 5:50 am
Posts: 6
Hi,

I have a parent/child relationship.
My child table has several million records.

I've just migrated from EJB entity beans to hibernate, and everything works fine, except that I can't add a child to a parent withou causing hibernate to read all child entities into the collection.

I do something like this

variable = getVariable( ... );
sample = new Sample( ... );
variable.getSamples().add( sample );

this takes a lot of time, because hibernate fills the collection with all the samples.

any ideias on how to improve mapping/code to get rid of this and generate just one insert statement ?

I've read chapter 8 of the docs, and serached through the forum...

thanks


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 6:44 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
If your model allows it then do sample.setVariable(v);

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 8:01 am 
Newbie

Joined: Mon Sep 29, 2003 5:50 am
Posts: 6
ok, I'll change my model to accomodate that.

just to clarify, it's impossible to add to a collection withou loading it ?

thanks
Ricardo


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2003 8:34 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Bags and lists may be added to without initializing.

This is because of the return value of add().


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.