-->
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: <bag/> mapping always wants to be lazy?
PostPosted: Mon May 03, 2004 9:33 am 
Newbie

Joined: Wed Apr 28, 2004 6:44 am
Posts: 15
Location: Amsterdam, Netherlands
Hi,

Using hibernate 2.1.3, I have a relationship mapped as a <set/>. However, I prefer a <bag/> so I changed the mapping, changed the code to instantiate a net.sf.hibernate.collection.Bag, and re-deployed the application. Now I'm getting LazyInitializationExceptions...

From the mapping:

Code:
      <bag
         cascade="all"
         inverse="true"
         lazy="false"
         name="billings"
      >
         <key column="POLIDX" />
         <one-to-many class="Billing" />
      </bag>



It used to be a <set/>, all I changed in the mapping was to replace the <set/> tag with a <bag/> tag.
Should I have changed more in the mapping?

The exception is:
Code:
net.sf.hibernate.LazyInitializationException: Failed to lazily initialize a collection - no session or session was closed
   at net.sf.hibernate.collection.PersistentCollection.initialize(PersistentCollection.java:209)
   at net.sf.hibernate.collection.PersistentCollection.read(PersistentCollection.java:71)
   at net.sf.hibernate.collection.Bag.size(Bag.java:232)
   at com.unisys.pdg.gi.incoming.ReceiveNewScheduleBean.removeObsoleteBillings(ReceiveNewScheduleBean.java:450)
   at com.unisys.pdg.gi.incoming.ReceiveNewScheduleBean.storeBillings(ReceiveNewScheduleBean.java:355)
   at com.unisys.pdg.gi.incoming.ReceiveNewScheduleBean.storePolicyAndBillings(ReceiveNewScheduleBean.java:332)
   at com.unisys.pdg.gi.incoming.ReceiveNewScheduleBean.processIncomingMessage(ReceiveNewScheduleBean.java:151)
   at com.unisys.pdg.gi.incoming.EJSLocalStatelessReceiveNewSchedule_1638c822.processIncomingMessage(Unknown Source)
   at com.unisys.pdg.common.incoming.ReceiveMessageHelperBean.processMessage(ReceiveMessageHelperBean.java:185)
   at com.unisys.pdg.common.incoming.EJSLocalStatelessReceiveMessageHelper_a67fe650.processMessage(Unknown Source)
   at com.unisys.pdg.common.jms.ReceiveMessage.handleMessage(ReceiveMessage.java:643)
   at com.unisys.pdg.common.jms.ReceiveMessage.onMessage(ReceiveMessage.java:376)
   at com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java(Compiled Code))
   at java.security.AccessController.doPrivileged(Native Method)
   at com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java(Compiled Code))
   at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java(Compiled Code))
   at com.ibm.mq.jms.MQSession.run(MQSession.java(Compiled Code))
   at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java(Compiled Code))
   at com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java(Compiled Code))
   at com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java(Compiled Code))
   at com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java(Compiled Code))
   at java.lang.reflect.Method.invoke(Native Method)
   at com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java(Compiled Code))
   at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java(Compiled Code))
   at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java(Compiled Code))
   at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java(Compiled Code))
   at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))



What other information do I need to post?

regards,

--Tim


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 10:21 am 
Newbie

Joined: Wed Apr 28, 2004 6:44 am
Posts: 15
Location: Amsterdam, Netherlands
Actually I think I solved my own problem... I shouldn't create a new instance of a Bag myself, at least not without giving it an instance of a SessionImplementor.

My own code should just create an instance of some other type.

--Tim


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.