When simplifying the code from
@Action public void action() throws Exception{ setPercentWorkerWorkpackageUpdatingNumEstimatedHoursMonth(); } public void setPercentWorkerWorkpackageUpdatingNumEstimatedHoursMonth() throws Exception{ if(logicContext.getVerb()==Verb.UPDATE){} }
to
@Action(verbs = Verbs.UPDATE) public void setPercentWorkerWorkpackageUpdatingNumEstimatedHoursMonth() throws Exception{
we get the following exception. Any issue?
~~~~~~
13:02:29 20/09/2012 -> DefaultHibernateOntimizeEntity -> Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
13:02:29 20/09/2012 -> javax.persistence.RollbackException: Error while committing the transaction
13:02:29 20/09/2012 -> at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:93)
13:02:29 20/09/2012 -> at com.ontimize.jpa.reference.PersistenceReference.commitEntityTransaction(PersistenceReference.java:132)
13:02:29 20/09/2012 -> at com.ontimize.jpa.db.PersistenceOntimizeEntity.update(PersistenceOntimizeEntity.java:489)
13:02:29 20/09/2012 -> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:02:29 20/09/2012 -> at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
13:02:29 20/09/2012 -> at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
13:02:29 20/09/2012 -> at java.lang.reflect.Method.invoke(Method.java:597)
13:02:29 20/09/2012 -> at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
13:02:29 20/09/2012 -> at sun.rmi.transport.Transport$1.run(Transport.java:159)
13:02:29 20/09/2012 -> at java.security.AccessController.doPrivileged(Native Method)
13:02:29 20/09/2012 -> at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
13:02:29 20/09/2012 -> at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
13:02:29 20/09/2012 -> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
13:02:29 20/09/2012 -> at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
13:02:29 20/09/2012 -> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
13:02:29 20/09/2012 -> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
13:02:29 20/09/2012 -> at java.lang.Thread.run(Thread.java:662)
13:02:29 20/09/2012 -> Caused by: javax.persistence.OptimisticLockException: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
13:02:29 20/09/2012 -> at org.hibernate.ejb.AbstractEntityManagerImpl.wrapStaleStateException(AbstractEntityManagerImpl.java:1428)
13:02:29 20/09/2012 -> at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1334)
13:02:29 20/09/2012 -> at org.hibernate.ejb.AbstractEntityManagerImpl.convert(AbstractEntityManagerImpl.java:1315)
13:02:29 20/09/2012 -> at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:81)
13:02:29 20/09/2012 -> ... 16 more
13:02:29 20/09/2012 -> Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
13:02:29 20/09/2012 -> at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
13:02:29 20/09/2012 -> at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
13:02:29 20/09/2012 -> at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:47)
13:02:29 20/09/2012 -> at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2590)
13:02:29 20/09/2012 -> at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2494)
13:02:29 20/09/2012 -> at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2821)
13:02:29 20/09/2012 -> at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:113)
13:02:29 20/09/2012 -> at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:273)
13:02:29 20/09/2012 -> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:265)
13:02:29 20/09/2012 -> at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:185)
13:02:29 20/09/2012 -> at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
13:02:29 20/09/2012 -> at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
13:02:29 20/09/2012 -> at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
13:02:29 20/09/2012 -> at com.autobizlogic.abl.hibernate.BeforeTransactionProcess.doBeforeTransactionCompletion(BeforeTransactionProcess.java:97)
13:02:29 20/09/2012 -> at org.hibernate.engine.ActionQueue$BeforeTransactionCompletionProcessQueue.beforeTransactionCompletion(ActionQueue.java:543)
13:02:29 20/09/2012 -> at org.hibernate.engine.ActionQueue.beforeTransactionCompletion(ActionQueue.java:216)
13:02:29 20/09/2012 -> at org.hibernate.impl.SessionImpl.beforeTransactionCompletion(SessionImpl.java:571)
13:02:29 20/09/2012 -> at org.hibernate.jdbc.JDBCContext.beforeTransactionCompletion(JDBCContext.java:250)
13:02:29 20/09/2012 -> at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:138)
13:02:29 20/09/2012 -> at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
13:02:29 20/09/2012 -> ... 16 more
Anonymous
I am not able to reproduce this problem. The stack trace does not seem to contain any relevant information. Are you absolutely sure that the only change is as indicated?
To try to reproduce the problem, I have created a logic class with the following:
I then wrote a simple test program that updates an object, and the action got called as expected, without any exception.
Would you have a more complete stack trace, and/or log, so we could try to locate the problem more precisely?