-->
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: net.sf.hibernate.LazyInitializationException:.....
PostPosted: Sat Mar 20, 2004 8:09 am 
Regular
Regular

Joined: Mon Jan 19, 2004 10:39 pm
Posts: 84
Location: Nottingham, England
...Exception initializing proxy: [test.Artist#32]

Note: I am using Hibernate 2.1.1

Hi,
I have 2 maps, Artist (parent) and ArtistImages (child). There is a one-to-one from parent to child and from child to parent. The child map has a foreign key generator as I need a child record to share the same id as the parent when a record is created.
Now maybe my understanding is wrong here, but I was under the impression that when loading a map which has a rference to another, in this case a one-to-one reference, that any associated records in the child map referenced by the same id as the parent would be loaded!?? So what wrong with what I am trying to do in the following instance??

My parent map is:

<hibernate-mapping package="test">
<class name="Artist" table="artisttbl" proxy="Artist">
<id name="ID" column="artist_id">
<generator class="sequence">
<param name="sequence">artist_seq_id</param>
</generator>
</id>
..........
<one-to-one name="ArtistImages" constrained="true" outer-join="false" class="ArtistImages" cascade="delete"/>
</class>
</hibernate-mapping>

My child map is:
<hibernate-mapping package="test">
<class name="ArtistImages" table="artistimagestbl">
<id name="ID" column="artist_id">
<generator class="foreign">
<param name="property">Artist</param>
</generator>
</id>
................
<one-to-one name="Artist" class="Artist" constrained="true"/>
</class>
</hibernate-mapping>

My method is:

transaction = session.beginTransaction();
//Get Artist details
artist = (Artist)session.load(Artist.class, artistID);
transaction.commit();
Util.closeSession();

My calling code is:
Artist artist = Artist.getArtist(artistID);
String artist_name = artist.getArtistName();
String artist_info = artist.getArtistInfo();

Full exception chain Stack trace:

Original Exception: net.sf.hibernate.LazyInitializationException: Exception initializing proxy: [test.Artist#32]
at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:61)
at net.sf.hibernate.proxy.LazyInitializer.getImplementation(LazyInitializer.java:161)
at net.sf.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:108)
at test.Artist$$EnhancerByCGLIB$$5548aedc.getArtistName(<generated>)
at org.apache.cocoon.www.beyarecords.xsp.artist_details_xsp.generate(org.apache.cocoon.www.beyarecords.xsp.artist_details_xsp:167)
at org.apache.cocoon.generation.ServerPagesGenerator.generate(ServerPagesGenerator.java:263)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.processXMLPipeline(AbstractProcessingPipeline.java:581)
at org.apache.cocoon.components.pipeline.impl.AbstractCachingProcessingPipeline.processXMLPipeline(AbstractCachingProcessingPipeline.java:196)
at org.apache.cocoon.components.pipeline.AbstractProcessingPipeline.process(AbstractProcessingPipeline.java:525)
at org.apache.cocoon.components.treeprocessor.sitemap.SerializeNode.invoke(SerializeNode.java:155)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:165)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:162)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:136)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:371)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:312)
at org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(MountNode.java:133)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:84)
at org.apache.cocoon.components.treeprocessor.sitemap.PreparableMatchNode.invoke(PreparableMatchNode.java:165)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(PipelineNode.java:162)
at org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode.invokeNodes(AbstractParentProcessingNode.java:107)
at org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(PipelinesNode.java:136)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:371)
at org.apache.cocoon.components.treeprocessor.TreeProcessor.process(TreeProcessor.java:312)
at org.apache.cocoon.Cocoon.process(Cocoon.java:656)
at org.apache.cocoon.servlet.CocoonServlet.service(CocoonServlet.java:1112)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:324)
at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:395)
at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:673)
at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:615)
at org.apache.jk.common.SocketConnection.runIt(ChannelSocket.java:786)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:552)
Caused by: net.sf.hibernate.HibernateException: Could not initialize proxy - the owning Session was closed
at net.sf.hibernate.proxy.LazyInitializer.initialize(LazyInitializer.java:47)
at net.sf.hibernate.proxy.LazyInitializer.initializeWrapExceptions(LazyInitializer.java:57)
... 55 more


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 24, 2004 6:03 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
<class name="Artist" table="artisttbl" proxy="Artist">
proxy="Artist" means Hibernate will not hit the DB unless it really needs it. Getting the artist name is one of that need.

_________________
Emmanuel


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.