-->
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: problem with option lazy="false"
PostPosted: Wed Sep 14, 2005 7:49 am 
Newbie

Joined: Fri May 20, 2005 4:34 am
Posts: 4
Hello,

I have a problem by fetching data. Normaly I want to get Object when they are needed, so I set the mapping option for my relation with lazy="false". But when I load a structure from DB with an object that only should be loaded if neccessary, I get the following error:

first some facts:
- I use Hibernate version 3.0.5

this is a part of my mapping:

...
<many-to-one name="singleValueTest" class="de.fhg.iwu.traceability.data.tests.SingleValueTest" column="VALUETEST_ID" unique="false" cascade="all" lazy="false" />
...

and

...
<joined-subclass name="SingleValueTest" table="SINGLEVALUETEST">
<key column="VALUETEST_ID" />

<joined-subclass name="EqualsTest" table="EQUALSTEST">
<key column="VALUETEST_ID" />

<property name="nominalValue" not-null="true" type="serializable" length="1000000">
<column name="NOMINALVALUE" />
</property>
</joined-subclass>

<joined-subclass name="BoundsTest" table="BOUNDSTEST">
<key column="VALUETEST_ID" />

<property name="lowerBound" type="double" not-null="true" >
<column name="LOWERBOUND" index="ind_BOUNDSTEST_LOWERBOUND" />
</property>

<property name="upperBound" type="double" not-null="true" >
<column name="UPPERBOUND" index="ind_BOUNDSTEST_LOWERBOUND" />
</property>

</joined-subclass>

</joined-subclass>
...

the following error occurs:

14.09.2005 13:47:57 org.hibernate.LazyInitializationException <init>
SCHWERWIEGEND: could not initialize proxy - the owning Session was closed
org.hibernate.LazyInitializationException: could not initialize proxy - the owning Session was closed
at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:53)
at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:80)
at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
at de.fhg.iwu.traceability.data.tests.SingleValueTest$$EnhancerByCGLIB$$df2757de.deepCopy(<generated>)
...

THANX for help - Tino Langer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 12:13 pm 
Senior
Senior

Joined: Tue Feb 08, 2005 5:26 pm
Posts: 157
Location: Montréal, Québec - Canada
Your problem does not come from the mapping. It comes from your session management.

If you have entity A and entity B (A lazy relation to B)

There can be two possible reasons:

1 - our session is closed when you call A.getB
or,
2 -You have an open session, but it is not the on in which A was loaded.


For case 1, make sure that the scope of the session spans your whole process.

For case 2, either reload A from the DB prior to calling A.getB, or try to reassociate A to the session.

Hope that helps,

_________________
Vincent Giguère
J2EE Developer


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 15, 2005 3:11 pm 
Newbie

Joined: Fri Sep 02, 2005 7:36 pm
Posts: 6
Post your dao.


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.