Joined: Tue Feb 07, 2006 1:32 pm Posts: 7 Location: Toronto, Ontario
|
Hi,
I use Hibernate (3.0) to insert a record into an Oracle 9.1 database. The following code is ultimatelly called by a Web Service to save in the database:
try
{
//Save the record
this.session.save(this.entity, aRequest);
this.session.flush();
} catch (HibernateException e)
{
logger.error(">>>>>>>>>>>>>>>>>>>>>>>>>>Hibernate Exception");
PendingItemsUtil.closeSession();
throw e;
}
I am getting the session previously when this DAO class is instantiated with:
public static Session currentSession() {
Session s = (Session) session.get();
// Open a new Session, if this Thread has none yet
if (s == null) {
logger.debug("Session was null, creating a new one");
s = sessionFactory.openSession();
session.set(s);
} else if (!s.isOpen() || s.isDirty()){
logger.debug("Session is open " + s.isOpen());
logger.debug("Session is dirty " + s.isDirty());
s.close();
s = sessionFactory.openSession();
session.set(s);
}
return s;
}
Normally everything works fine but at some point I have the StaleObjectException in my log files:
27/Apr/2006 09:38:42.076 ERROR Transaction "1146145117045 GDP_11461451085451111" - [org.hibernate.event.def.AbstractFlushingEventListener] Could not synchronize database state with session
org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [GDPPendingItem#11943719348038349181146145110326Server_13]
at org.hibernate.persister.entity.BasicEntityPersister.check(ILjava.io.Serializable;I)Z(BasicEntityPersister.java:1431)
at org.hibernate.persister.entity.BasicEntityPersister.update(Ljava.io.Serializable;[Ljava.lang.Object;[Ljava.lang.Object;Ljava.lang.Object;[ZILjava.lang.Object;Ljava.lang.Object;Ljava.lang.String;Lorg.hibernate.engine.SessionImplementor;)Z(BasicEntityPersister.java:1976)
at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(Ljava.io.Serializable;[Ljava.lang.Object;[Ljava.lang.Object;Ljava.lang.Object;[ZILjava.lang.Object;Ljava.lang.Object;Ljava.lang.String;Lorg.hibernate.engine.SessionImplementor;)V(BasicEntityPersister.java:1899)
at org.hibernate.persister.entity.BasicEntityPersister.update(Ljava.io.Serializable;[Ljava.lang.Object;[IZ[Ljava.lang.Object;Ljava.lang.Object;Ljava.lang.Object;Ljava.lang.Object;Lorg.hibernate.engine.SessionImplementor;)V(BasicEntityPersister.java:2139)
at org.hibernate.action.EntityUpdateAction.execute()V(EntityUpdateAction.java:75)
at org.hibernate.engine.ActionQueue.execute(Lorg.hibernate.action.Executable;)V(ActionQueue.java:239)
at org.hibernate.engine.ActionQueue.executeActions(Ljava.util.List;)V(ActionQueue.java:223)
at org.hibernate.engine.ActionQueue.executeActions()V(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(Lorg.hibernate.engine.SessionImplementor;)V(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(Lorg.hibernate.event.FlushEvent;)V(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush()V(SessionImpl.java:678)
at com.intria.bip.pendingitems.dao.PendingItemsDAO.insertRequest(Lcom.intria.bip.pendingitems.dao.PendingItemRecord;)V(PendingItemsDAO.java:160)
at com.intria.bip.pendingitems.dao.PendingItemsDAO.updateRequestStatus(Ljava.lang.String;Ljava.lang.String;)V(PendingItemsDAO.java:129)
at com.intria.bip.controller.command.ArchiveGetRequestedItemsCommand.execute(Lcom.intria.bip.bo.request.BIPRequest;)Lcom.intria.bip.bo.response.BIPResponse;(ArchiveGetRequestedItemsCommand.java:62)
at com.intria.bip.controller.ItemArchiveService.processTask(Lcom.intria.bip.bo.request.BIPRequest;)Lcom.intria.bip.bo.response.BIPResponse;(ItemArchiveService.java:138)
at com.intria.bip.controller.BIP.serveRequest(Lcom.intria.bip.bo.request.BIPRequest;)Lcom.intria.bip.bo.response.BIPResponse;(BIP.java:93)
at com.intria.bip.webservices.operationhandlers.GetRequestedItemsOperationHandler.executeMyTransaction(Ljava.lang.Object;)Ljava.lang.Object;(GetRequestedItemsOperationHandler.java:69)
at com.intria.bip.webservices.operationhandlers.BIPOperationHandler.access$000(Lcom.intria.bip.webservices.operationhandlers.BIPOperationHandler;Ljava.lang.Object;)Ljava.lang.Object;(BIPOperationHandler.java:31)
at com.intria.bip.webservices.operationhandlers.BIPOperationHandler$1.executeTransaction()Ljava.lang.Object;(BIPOperationHandler.java:48)
at com.intria.bip.webservices.common.operationhandlers.OperationProcessor.execute(Lcom.intria.bip.webservices.common.operationhandlers.OperationHandler;)Ljava.lang.Object;(OperationProcessor.java:83)
at com.intria.bip.webservices.operationhandlers.BIPOperationHandler.execute(Ljava.lang.Object;)Ljava.lang.Object;(BIPOperationHandler.java:61)
at com.intria.bip.webservices.BIPServiceImpl.getRequestedItems(Lcom.intria.bip.webservices.types.message.GetRequestedItemsRequest;)Lcom.intria.bip.webservices.types.message.GetRequestedItemsResponse;(BIPServiceImpl.java:121)
at jrockit.reflect.NativeMethodInvoker.invoke0(Ljava.lang.Object;ILjava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at jrockit.reflect.NativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at jrockit.reflect.VirtualNativeMethodInvoker.invoke(Ljava.lang.Object;[Ljava.lang.Object;)Ljava.lang.Object;(Unknown Source)
at java.lang.reflect.Method.invoke(Ljava.lang.Object;[Ljava.lang.Object;I)Ljava.lang.Object;(Unknown Source)
at com.systinet.wasp.server.adaptor.JavaInvoker.invokeService()Z(JavaInvoker.java:1528)
at com.systinet.wasp.server.adaptor.JavaInvoker.endInvoke(Lcom.systinet.wasp.webservice.CurrentImpl$ThreadLocals;Ljavax.xml.rpc.handler.soap.SOAPMessageContext;Lcom.idoox.util.Pool;)V(JavaInvoker.java:542)
at com.idoox.wasp.server.adaptor.JavaAdaptorImpl.endInvoke(Lcom.systinet.wasp.webservice.CurrentImpl$ThreadLocals;Ljavax.xml.rpc.handler.soap.SOAPMessageContext;Lcom.systinet.wasp.webservice.ServiceEndpointImpl;)V(JavaAdaptorImpl.java:76)
at com.idoox.wasp.server.AdaptorTemplate.javaInvocation(Lcom.systinet.wasp.webservice.CurrentImpl$ThreadLocals;Ljavax.xml.rpc.handler.soap.SOAPMessageContext;Lcom.systinet.wasp.webservice.ServiceEndpointImpl;Lorg.idoox.transport.Connection;Lcom.idoox.wasp.server.AdaptorTemplate$MessageWrapper;Lorg.idoox.xml.Tokenizer;)Z(AdaptorTemplate.java:561)
at com.idoox.wasp.server.AdaptorTemplate.doDispatch(Lorg.idoox.transport.Connection;Lcom.systinet.wasp.webservice.CurrentImpl$ThreadLocals;Lcom.systinet.wasp.webservice.ServiceEndpointImpl;Lcom.systinet.wasp.webservice.VersionCollection;)V(AdaptorTemplate.java:395)
at com.idoox.wasp.server.AdaptorTemplate.dispatch(Lcom.systinet.wasp.webservice.CurrentImpl$ThreadLocals;Lorg.idoox.transport.Connection;Lcom.systinet.wasp.webservice.ServiceEndpointImpl;Lcom.systinet.wasp.webservice.VersionCollection;)V(AdaptorTemplate.java:328)
27/Apr/2006 09:38:42.076 DEBUG Transaction "1146145117045 GDP_11461451085451111" - [org.hibernate.impl.SessionImpl] closing session
27/Apr/2006 09:38:42.076 DEBUG Transaction "1146145117045 GDP_11461451085451111" - [org.hibernate.jdbc.AbstractBatcher] closing JDBC connection
In the hbm.xml files I specified the unsaved-value attribute so I don't think this is the case. Could you please help me to identify the cause of this exception?
Thank you.
|
|