-->
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: ManyToOne and lazy loading (again?)
PostPosted: Fri Jul 25, 2008 6:48 am 
Newbie

Joined: Fri Jul 25, 2008 6:26 am
Posts: 3
Hibernate version:
3.2.6 GA

Hi,

i have 3 Entities:

Person: has many Documents (OneToMany)
Document: has one DBFile (ManyToOne)
DBFile: contains the filecontent and such

Everytime when i access Person#getDocuments() the associated DBFile is also retrieved which leads to an OutOfMemoryException after a short time ...

How can i prevent this? (which annotations do i have to set where?)


I found http://www.hibernate.org/162.html but setting
@ManyToOne(optional=false) on Document#getDBFile() didn't help.

On Jira i found some issues which have all been rejected with comment "read the documenatation" - very patronizing ... at least they could give a link to the right place


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 9:45 am 
Expert
Expert

Joined: Tue May 13, 2008 3:42 pm
Posts: 919
Location: Toronto & Ajax Ontario www.hibernatemadeeasy.com
Out of memory means just that. Is this a huge object graph?

Make sure the associated entities are loaded in a lazy manner, that's for sure.

_________________
Cameron McKenzie - Author of "Hibernate Made Easy" and "What is WebSphere?"
http://www.TheBookOnHibernate.com Check out my 'easy to follow' Hibernate & JPA Tutorials


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 25, 2008 10:02 am 
Newbie

Joined: Fri Jul 25, 2008 6:26 am
Posts: 3
Cameron McKenzie wrote:
Out of memory means just that. Is this a huge object graph?

i load one person with about 8 documents. the oome comes because of the blob with the filecontent inside DBFile which is serveral megabytes.

Cameron McKenzie wrote:
Make sure the associated entities are loaded in a lazy manner, that's for sure.


thats what i'm trying and where i stuck. Document#getDBFile() wont get loaded lazy ...


Top
 Profile  
 
 Post subject: Solved!
PostPosted: Wed Aug 13, 2008 4:30 am 
Newbie

Joined: Fri Jul 25, 2008 6:26 am
Posts: 3
We found the bug. We called Document#getDBFile() inside Document#hashCode() and triggered the DBFile to be loaded.


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.