-->
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.  [ 5 posts ] 
Author Message
 Post subject: ERROR org.hibernate.LazyInitializationException - could not
PostPosted: Wed Oct 19, 2005 2:03 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 1:19 pm
Posts: 24
ERROR org.hibernate.LazyInitializationException - could not initialize proxy - the owning Session was closed.


Mapping:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1

http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->

<class
name="gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Wqvisit"
table="WQVISIT"
>

<id
name="visitId"
type="long"
column="VISIT_ID"
>
<generator class="assigned" />
</id>


<property
name="visitPersonName"
type="java.lang.String"
column="VISIT_PERSON_NAME"
not-null="true"
length="30"
/>

<property
name="dateOut"
type="java.sql.Date"
column="DATE_OUT"
length="7"
/>

<property
name="dateIn"
type="java.sql.Date"
column="DATE_IN"
not-null="true"
length="7"
/>
<property
name="visitComment"
type="java.lang.String"
column="VISIT_COMMENT"
length="4000"
/>
<property
name="flowId"
type="long"
column="FLOW_ID"
length="11"
/>
<property
name="dataFilePath"
type="java.lang.String"
column="DATA_FILE_PATH"
length="255"
/>

<!-- Associations -->

<!-- bi-directional many-to-one association to Wqsite -->
<many-to-one
name="wqsite"
lazy="false"
class="gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Wqsite"
not-null="true"
>
<column name="SITE_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to Monitor -->
<many-to-one
name="monitorByMonitorInId"
lazy="false"
class="gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Monitor"
not-null="true"
>
<column name="MONITOR_IN_ID" />
</many-to-one>
<!-- bi-directional many-to-one association to Monitor -->
<many-to-one
name="monitorByMonitorOutId"
lazy="false"
class="gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Monitor"
not-null="true"
>
<column name="MONITOR_OUT_ID" />
</many-to-one>


</class>
</hibernate-mapping>


I try to access wqsite set on the many-to-one relation above. I have lazy="false" but still get the error. I thought with lazy="false" all objects assoiciated are loaded completely. Any hints, I read the documentation and thought it states that I should have objects loaded when specifying lazy="false"

Thank You and forgive me if I am stupidly miss-understanding some obvious facts. I use hibernate 3.1


Top
 Profile  
 
 Post subject: Sorry I am using hibernate 3.1
PostPosted: Wed Oct 19, 2005 2:05 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 1:19 pm
Posts: 24
Sorry I am using hibernate 3.1


Top
 Profile  
 
 Post subject: Using hibernate 3.0
PostPosted: Wed Oct 19, 2005 2:09 pm 
Beginner
Beginner

Joined: Thu Jul 28, 2005 1:19 pm
Posts: 24
OK this is not going well. I am using hibernate 3.0.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:20 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
should post that question in the user forum - this forum is for tool related questions.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 8:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
There are class level lazy settings and property level lazy settings. Not sure about the the clas level settings for the other domain objects as you have not supplied them but check that you have lazy=false for all of the targeted domain objects. In the example you have shown it is lazy loaded - make sure the proxy setting in Middlegen to turn it off (or I might have a bug to fix).

For example you want the domain object to show:
Code:
<class
name="gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Wqvisit"
table="WQVISIT"
lazy="false"
>

for your many-to-one targeted domain objects


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