Hi,
I have a simple method to insert/update record in database.
Code:
public T makePersistent(T entity) {
getSession().saveOrUpdate(entity);
getSession().flush();
return entity;
}
When i try to call this method for a new record (i.e. for INSERT) it fails with org.hibernate.exception.LockAcquisitionException.
The error stack is mentioned below for your reference.
Any pointers will be of great help
Thanks in advance.
Regards,
Ranbir
Quote:
2010-02-23 15:31:12,447 WARN [QuartzScheduler_Worker-13] JDBCExceptionReporter - SQL Error: 1205, SQLState: 40001
2010-02-23 15:31:12,447 ERROR [QuartzScheduler_Worker-13] JDBCExceptionReporter - Your server command (family id #0, process id #313) encountered a deadlock situation. Please re-run your command.
2010-02-23 15:31:12,447 ERROR [QuartzScheduler_Worker-13] AbstractFlushingEventListener - Could not synchronize database state with session
org.hibernate.exception.LockAcquisitionException: could not update: [com.cim.model.MessageFileDefLevel#402883b526b600360126f9f370fa1bca]
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:82)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2425)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.cim.dao.hibernate.GenericHibernateDAO.makePersistent(GenericHibernateDAO.java:105)
at com.cim.process.HibernateMessenger.write(HibernateMessenger.java:91)
at com.cim.process.subprocess.SendOutputSubProcess.execute(SendOutputSubProcess.java:222)
at com.cim.process.Processor.process(Processor.java:253)
at com.cim.process.Processor.multipleProcess(Processor.java:212)
at com.cim.InterfaceJob.execute(InterfaceJob.java:95)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)
Caused by: com.sybase.jdbc3.jdbc.SybSQLException: Your server command (family id #0, process id #313) encountered a deadlock situation. Please re-run your command.
at com.sybase.jdbc3.tds.Tds.a(Unknown Source)
at com.sybase.jdbc3.tds.Tds.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.ResultGetter.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.nextResult(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.updateLoop(Unknown Source)
at com.sybase.jdbc3.jdbc.SybStatement.executeUpdate(Unknown Source)
at com.sybase.jdbc3.jdbc.SybPreparedStatement.executeUpdate(Unknown Source)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
... 17 more
2010-02-23 15:31:12,478 ERROR [QuartzScheduler_Worker-13] 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): [com.cim.model.MessageMasterProcess#25765]
at org.hibernate.persister.entity.AbstractEntityPersister.check(AbstractEntityPersister.java:1765)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2407)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2307)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2607)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:142)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
at com.cim.dao.hibernate.GenericHibernateDAO.makePersistent(GenericHibernateDAO.java:105)
at com.cim.process.HibernateMessenger.write(HibernateMessenger.java:91)
at com.cim.process.Processor.process(Processor.java:306)
at com.cim.process.Processor.multipleProcess(Processor.java:212)
at com.cim.InterfaceJob.execute(InterfaceJob.java:95)
at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:529)