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.  [ 3 posts ] 
Author Message
 Post subject: Component mapping and LazyInitializationException
PostPosted: Thu Apr 05, 2007 2:49 am 
Newbie

Joined: Thu Mar 08, 2007 5:14 pm
Posts: 6
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

NHibernate version: 1.0.2


Name and version of the database you are using: SQLServer 2005

Hello,

I have following problem:
In my project I have an object Order, which is connected with Validity. In Validity there are two Time objects - each has DateTime property and code property. In ORDER table Validity is mapped as component (columns with foreign key for Time objects - START_TIME and END_TIME). The relation in <component> is many-to-one. I set fetch="join" for both START_TIME and END_TIME. When I retrieve Order from database startTime in Validity is loaded properly, but endTime is not and I get LazyInitializationException. In mapping of Time lazy is set to true. If I set it to false - everything works just fine. But with lazy=true I keep getting LazyInitializationException. What should I do to load both Time objects in Validity when retrieving Order from database ?

Best regards.
tytus


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 4:02 am 
Senior
Senior

Joined: Mon Aug 21, 2006 9:18 am
Posts: 179
You'll want to post mappings and the code you use to between session open and close until error so we can help you.
Are you accessing the End_Time property after the session has flushed, but the Start_time is getting accessed while it is available? That exception usually indicates that your proxy is trying to initialize but the session is closed.
MIKE

_________________
If this helped...please remember to rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 05, 2007 5:59 am 
Newbie

Joined: Thu Mar 08, 2007 5:14 pm
Posts: 6
Hello,

Session is already closed - and there is no surprise for me that there is LazyInitializationException because of that. I wonder - if there is fetch="join" set, shouldn't the Time objects be already loaded when retrieving Order from database? How can I set (in mapping - component tag) Time objects to be loaded with Order object? Isn't fetch="join" enough? I would like to avoid changing lazy=true to lazy=false for Time object...


Best regards,
tytus


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.