-->
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: LazyInitializationException?
PostPosted: Tue Nov 01, 2005 10:12 pm 
Hi,
one-to-many:
Users.hbm.xml:
<id name="id" column="Userid" type="java.lang.String">
<generator class="assigned"/>
</id>
<property name="regtime" column="Regtime" type="java.util.Calendar" />
<set name="bbsTopicSet" lazy="false" cascade="all" inverse="true">
<key column="Creator"/>
<one-to-many class="BbsTopic"/>

bbsTopicSet.hbm.xml:
<many-to-one name="Users" column="Creator" class="SysUsers" update="true" insert="true"/>

bbstopic.getSysUsers().getId() will be ok,but if bbstopic.getSysUsers().getRegtime(),it can not work:
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed

why?


Top
  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 10:23 pm 
Newbie

Joined: Tue Nov 01, 2005 9:55 pm
Posts: 14
It looks like the association of many-to-one is not defined as eager and so loads a proxy for SysUsers, which holds the id of the SysUsers entity in order to lazily load it later.
Maybe adding a lazy="false" to the many-to-one association will solve your problem?


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.