• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Batch update returned unexpected

 
suraj savaratkar
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Im trying to update the existing data with new values using session.update() mehod, but data has updating but when i going to commit this data using session.beginTransaction().commit(); it thrown an exception like;


session.update(capbuild);
session.beginTransaction().commit();
session.flush();
session.close();



org.hibernate.StaleStateException: Batch update returned unexpected row count from update: 0 actual row count: 0 expected: 1
at org.hibernate.jdbc.BatchingBatcher.checkRowCount(BatchingBatcher.java:88)
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:74)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:57)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:154)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:226)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:137)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:669)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:293)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
at com.seed.ftts.dao.ToCapabilityBuildingDAO.updateCapBuild(ToCapabilityBuildingDAO.java:311)
at com.seed.ftts.techOffice.CapabiltyBuildingAction.updateCapBuild(CapabiltyBuildingAction.java:228)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:399)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:262)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:213)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterIntercepto

I was finding the solution last three days, please help.

 
Christian Dillinger
Ranch Hand
Posts: 200
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That exception tells you that a row has been changed or deleted since your batch process read it. Do you have a version or a timestamp field to use optimistic locking? Are there other users online while your job is running? Does your job access the same data twice in different transactions?
 
suraj savaratkar
Ranch Hand
Posts: 96
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

I found the solution, Exception thrown because I was not given any Serailizable arguments to update that row. That why it's confussed which row it should be updated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic