-->
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: one-to-many, mapping
PostPosted: Mon Nov 14, 2005 11:35 am 
Newbie

Joined: Mon Nov 14, 2005 11:09 am
Posts: 2
Hi,
I'm using Hibernate 3.1. I have the following scenario:
I have a parent object encapsulating a List of child objects inside it. There are two tables in the database (SYBASE), which stores this identity mapping with the help of an Id column. When trying to retrieve the parent and print the child, it gives the following exception:

org.hibernate.LazyInitializationException: cannot access loading collection

If I load the parent and the child(explicitly, by executing an SQL), then it works fine. In the mapping file I have tried both lazy="false" and "true". Doesn't make a difference !

I'm completely new to hibernate. Could any one please help me out with this?
regards,
Saurabh

_________________
--
Saurabh Agarwal


Top
 Profile  
 
 Post subject: have session opern
PostPosted: Mon Nov 14, 2005 12:25 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
In general if lazy=”false” then everything should work just fine. You may see the same exception because child object in turn might have some lazy association and that may create appearance of lazy=”false” not working.

If you need all the data anyway than it make sense to use lazy=”false” all the time, otherwise you need to implement “open-session-in-view” or “Session-per_request strategy.
http://www.hibernate.org/43.html

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.