Hi all,
I have a weird issue. I am trying to update multiple entities of the same type in one transaction. If the transaction only has one entity that needs updating then everything works fine. If I do the same process as with the one entity but do it multiple times it fails!!
Anybody got ideas?
Cheers
Tom
Hibernate version:
Its the version with JBoss 4.0sp1
2.1.8 I think
Mapping documents: There are two documents that need consideration. A TransportDestination has a TransportType and a TransportType has multiple TransportDestinations.
TransportType:
<class name="com.camp.common.transport.TransportType" table="tblTransportType">
<id name="ID" type="integer">
<column name="id_transport_type" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">tbltransporttype_id_transport_type_seq</param>
</generator>
</id>
<property name="transportType">
<column name="transport_type" sql-type="char(64)" not-null="true"/>
</property>
<property name="sessionName">
<column name="session_name" sql-type="char(64)" not-null="true"/>
</property>
<set name="destinations" lazy="false" cascade="all-delete-orphan" inverse="true">
<key column="fk_id_transport_type"/>
<one-to-many class="com.camp.common.transport.TransportDestination"/>
</set>
</class>
AND TransportDestination
<class name="com.camp.common.transport.TransportDestination" table="tblTransportDestination">
<id name="ID" type="integer">
<column name="id_destination" sql-type="integer" not-null="true"/>
<generator class="sequence">
<param name="sequence">tbltransportdestination_id_destination_seq</param>
</generator>
</id>
<property name="code">
<column name="code" sql-type="char(3)" not-null="true"/>
</property>
<property name="name">
<column name="name" sql-type="char(128)"/>
</property>
<property name="city">
<column name="city" sql-type="char(128)" not-null="true"/>
</property>
<property name="state">
<column name="state" sql-type="char(128)" not-null="true"/>
</property>
<property name="country">
<column name="country" sql-type="char(128)" not-null="true"/>
</property>
<property name="listed">
<column name="listed" sql-type="boolean" not-null="true"/>
</property>
<many-to-one name="transportType" class="com.camp.common.transport.TransportType" column="fk_id_transport_type" not-null="true"/>
</class>
Code between sessionFactory.openSession() and session.close():
Note: _transport_destinations = java.util.List
// Open Session
sess = sf.openSession();
// Create Transaction
Transaction t = sess.beginTransaction();
TransportDestination dest;
t = sess.beginTransaction();
//repeat as many times as there are destinations in the list
for (int i = 0; i < _transport_destinations.size(); i++) {
//get the destination
dest = (TransportDestination) _transport_destinations.get(i);
if (_operation.equals(Globals.ADD))
sess.save(dest);
else if (_operation.equals(Globals.UPDATE))
sess.update(dest);
else if (_operation.equals(Globals.DELETE))
sess.delete(dest);
}
t.commit();
sess.close();
Full stack trace of any exception that occurs:
11:58:38,480 INFO [STDOUT] Hibernate: update tblTransportDestination set code=?, name=?, city=?, state=?, country=?, listed=?, fk_id_transport_type=? where id_destination=?
11:58:38,480 INFO [STDOUT] Hibernate: update tblTransportDestination set code=?, name=?, city=?, state=?, country=?, listed=?, fk_id_transport_type=? where id_destination=?
11:58:38,480 INFO [STDOUT] Hibernate: update tblTransportDestination set code=?, name=?, city=?, state=?, country=?, listed=?, fk_id_transport_type=? where id_destination=?
11:58:38,488 INFO [transportEJB] Leaving modifyTransportDestinations
11:58:38,565 ERROR [TxInterceptorBMT] Application error: BMT stateless bean transport should complete transactions before returning (ejb1.1 spec, 11.6.1)
11:58:38,567 WARN [RequestProcessor] Unhandled Exception thrown: class java.rmi.RemoteException
11:58:38,568 ERROR [Engine] StandardWrapperValve[camp]: Servlet.service() for servlet camp threw exception
java.rmi.RemoteException: Application error: BMT stateless bean transport should complete transactions before returning (ejb1.1 spec, 11.6.1)
at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.checkStatelessDone(AbstractTxInterceptorBMT.java:208)
at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:157)
at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:113)
at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:122)
at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:191)
at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
at org.jboss.ejb.Container.invoke(Container.java:856)
at sun.reflect.GeneratedMethodAccessor102.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:144)
at org.jboss.mx.server.Invocation.dispatch(Invocation.java:80)
at org.jboss.mx.server.Invocation.invoke(Invocation.java:72)
at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:249)
at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:642)
at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:155)
at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:104)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:90)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:55)
at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:97)
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:86)
at $Proxy84.modifyTransportDestinations(Unknown Source)
at com.camp.helpers.config.transport.TransportConfigHelper.modifyTransportDestinations(Unknown Source)
at com.camp.actions.config.TransportConfigAction.execute(Unknown Source)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:186)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:153)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:54)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Name and version of the database you are using:
The generated SQL (show_sql=true):
11:58:38,480 INFO [STDOUT] Hibernate: update tblTransportDestination set code=?, name=?, city=?, state=?, country=?, listed=?, fk_id_transport_type=? where id_destination=?
Debug level Hibernate log excerpt:
|