-->
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: How do you add to Collection without initialise whole collec
PostPosted: Sat Feb 09, 2008 6:16 am 
Newbie

Joined: Sat Nov 26, 2005 9:03 am
Posts: 5
I have a many-many relationship much like person-event in the hibernate tutorial. When I add an Event to a Persons events hibernate first initialises the whole Set. This is fine for a small set of events but whe you have 40,000 events etc this is inefficent. How do I fix this please?


Top
 Profile  
 
 Post subject:
PostPosted: Sat Feb 09, 2008 7:30 am 
Beginner
Beginner

Joined: Thu Jun 07, 2007 2:38 am
Posts: 28
Location: Italy, Rome
I suppose you already tried lazy loading?

Like
Code:
@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
with annotations?


Top
 Profile  
 
 Post subject: Re: How do you add to Collection without initialise whole co
PostPosted: Sat Feb 09, 2008 10:00 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Hi,

maybe you should not have a mapping for this huge set. The "LAZY" fetch type may not be a solution, because I think it is very likely that you will LOAD 40000 entities. It may be a solution just to map the other side and handle the other case with a native SQL query if needed.

Carlo


Top
 Profile  
 
 Post subject: Re: How do you add to Collection without initialise whole co
PostPosted: Sat Feb 09, 2008 10:01 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
carlolf wrote:
Hi,
it is very likely that ...


Of course I meant "UNlikely", sorry!

Carlo


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.