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


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 2:57 pm 
Expert
Expert

Joined: Wed Apr 06, 2005 5:03 pm
Posts: 273
Location: Salt Lake City, Utah, USA
I believe you need to also turn off proxies for the Wqsite class. Set lazy="false" on the <class> tag for gov.noaa.nwfsc.omi.sdm.wqbemp.hibernate.model.Wqsite.

_________________
nathan


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 19, 2005 3:03 pm 
Expert
Expert

Joined: Mon Feb 14, 2005 12:32 pm
Posts: 609
Location: Atlanta, GA - USA
What does your application code look like ?

_________________
Preston

Please don't forget to give credit if/when you get helpful information.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Oct 20, 2005 9:31 am 
Newbie

Joined: Sun Oct 16, 2005 3:14 pm
Posts: 9
Location: Israel
try to use

Hibernate.initialize(item.getWqsites());

_________________
Hanan

Please don't forget to give credit if/when you get helpful information.


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