-->
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.  [ 1 post ] 
Author Message
 Post subject: Session nulling out in AbstractCollectionPersister
PostPosted: Mon Jan 08, 2007 10:50 am 
Newbie

Joined: Thu Nov 09, 2006 2:44 pm
Posts: 2
Hibernate version: 3.1

Mapping documents:

Person
Code:
<bag name="relations" inverse="true" fetch="subselect">
   <subselect>select * from RELATIONS where TYPE = 8 or TYPE = 9</subselect>
   <key property-ref="id">
      <column name="ID" />
   </key>           
   <one-to-many class="Relations" not-found="ignore" />
</bag>


Relationship
Code:
<bag name="location" inverse="true" fetch="subselect">
     <key property-ref="relatedId">
       <column name="ID" />
     </key>
     <one-to-many class="Location"  not-found="ignore" />
</bag>


Location

Code between sessionFactory.openSession() and session.close():
My code is used inside of Spring's OpenSessionInViewFilter and is along the lines of:
Code:
Person person = session.get(Person.class....);
Castor.marshal(person);


Full stack trace of any exception that occurs:
Code:
01-05 19:58 DEBUG - org.hibernate.engine.StatefulPersistenceContext
01-05 19:58 DEBUG - initializing non-lazy collections
01-05 19:58 DEBUG - org.hibernate.loader.Loader
01-05 19:58 DEBUG - done loading collection
01-05 19:58 DEBUG - org.hibernate.event.def.DefaultInitializeCollectionEventListener
01-05 19:58 DEBUG - collection initialized
01-05 19:58 ERROR - org.hibernate.LazyInitializationException
01-05 19:58 ERROR - failed to lazily initialize a collection of role: hibernate.objects.ReplacedName.replacedCollection, no session or session was closed
org.hibernate.LazyInitializationException: failed to lazily initialize a collection of role: hibernate.objects.ReplacedName.replacedCollection, no session
        at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationException(AbstractPersistentCollection.java:358)
        at org.hibernate.collection.AbstractPersistentCollection.throwLazyInitializationExceptionIfNotConnected(AbstractPersistentCollection.java:350)
        at org.hibernate.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:343)
        at org.hibernate.collection.AbstractPersistentCollection.read(AbstractPersistentCollection.java:86)
        at org.hibernate.collection.PersistentBag.iterator(PersistentBag.java:246)
        at org.exolab.castor.mapping.loader.J2CollectionHandlers$3.elements(J2CollectionHandlers.java:163)
        at org.exolab.castor.mapping.loader.FieldHandlerImpl.getValue(FieldHandlerImpl.java:444)
        at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:197)
        at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:923)
        at org.exolab.castor.xml.Validator.validate(Validator.java:127)
        at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:252)
        at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:923)
        at org.exolab.castor.xml.Validator.validate(Validator.java:127)
        at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:279)
        at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:923)
        at org.exolab.castor.xml.Validator.validate(Validator.java:127)
        at org.exolab.castor.xml.FieldValidator.validate(FieldValidator.java:252)
        at org.exolab.castor.xml.util.XMLClassDescriptorImpl.validate(XMLClassDescriptorImpl.java:923)
        at org.exolab.castor.xml.Validator.validate(Validator.java:127)
        at org.exolab.castor.xml.Marshaller.validate(Marshaller.java:2471)
        at org.exolab.castor.xml.Marshaller.marshal(Marshaller.java:829)
        at replaced.services.marshalling.CastorMarshallingService.write(CastorMarshallingService.java:81)
        at replaced.services.marshalling.CastorMarshallingService.marshal(CastorMarshallingService.java:93)
        at replaced.services.ReplacedIntegrationServiceImpl.integrate(ReplacedIntegrationServiceImpl.java:105)
        at replaced.services.ReplacedIntegrationServiceImpl.integrate(ReplacedIntegrationServiceImpl.java:71)
        at replaced.web.EasterEggController.processFormSubmission(EasterEggController.java:95)
        at org.springframework.web.servlet.mvc.AbstractFormController.handleRequestInternal(AbstractFormController.java:250)
        at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:153)
        at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:45)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:806)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:736)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:396)
        at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:360)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
        at com.evermind.server.http.ResourceFilterChain.doFilter(ResourceFilterChain.java:65)
        at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
        at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:77)
        at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:604)
        at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:317)
        at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:790)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:270)
        at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:112)
        at com.evermind.util.ReleasableResourcePooledExecutor$MyWorker.run(ReleasableResourcePooledExecutor.java:186)
        at java.lang.Thread.run(Unknown Source)


Name and version of the database you are using:
Oracle 9.0.2

The generated SQL (show_sql=true):
Doesn't get that far.

Debug level Hibernate log excerpt:
Included above exception.

Basically, the Person has and XREF table (Relations) that return different type of Locations (Home address, work address, etc.); however, my applications bombs when the Person has the same Location for more than one Relationship (related to the same entity twice).

As mentioned above, the code is used inside of Spring's OpenSessionInViewFilter and is along the lines of:
Code:
Person person = session.get(Person.class....);
Castor.marshal(person);


So of course castor calls all of my getters and if it is a collection of some sort, it calls .iterate() to retrieve the values from an Abstract[Set|Collection]Persister. For some reason, the session becomes null in this class at some point but like I said, only when the same object is related twice.

I've tried lazy="true" and lazy="false". Different exceptions but same sort of error occur.

Any help is appreciated. I've got a deadline this week and I had to fight pretty hard to use Hibernate on this project. I'm hoping to resolve this so I don't get the "I told you so" look from upper management ;). Thanks in advance.

D


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.