• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Could not synchronize database state with session Unexpected row count: 0 expected: 1

 
shyam jakki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ALL

I got "Could not synchronize database state with session" exception while updating a child record in hibernate. This is same with many child update cases. Let us know any clue. Thanks in Advance.

Child Table is having a Composite Key. I have set all the keys of Composite key. I have changed one of the three values of the composite key, and used update method provided by the HibernateTemplate class. Help appreciated ASAP

Full stack trace:

[http-8080-Processor24] 27 Jun 2007 16:04:27,921 ERROR event.def.AbstractFlushingEventListener:277 - Could not synchronize database state with session

org.hibernate.HibernateException: Unexpected row count: 0 expected: 1

at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:32)

at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:1982)

at org.hibernate.persister.entity.BasicEntityPersister.updateOrInsert(BasicEntityPersister.java:1909)

at org.hibernate.persister.entity.BasicEntityPersister.update(BasicEntityPersister.java:2149)

at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:75)

at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)

at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)

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:730)

at org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:394)

at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:367)

at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:658)

at org.springframework.orm.hibernate3.HibernateTemplate.update(HibernateTemplate.java:654)

at com.ness.incentivo.admin.dao.EmpThrsldDAO.update(EmpThrsldDAO.java:47)

at com.ness.incentivo.admin.dao.EmpDAO.update(EmpDAO.java:589)

at com.ness.incentivo.delegate.EmpDelegate.updateEmp(EmpDelegate.java:129)

at com.ness.incentivo.web.admin.action.EmpAction.updateChilds(EmpAction.java:1096)

at com.ness.incentivo.web.admin.action.EmpAction.editSave(EmpAction.java:1539)

at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

at sun.reflect.NativeMethodAccessorImpl.invoke
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have changed one of the three values of the composite key, and used update


You have changed the composite id, which means this is a totally new record. You will have to use the insert (or is it called save?) method and not update method.
 
shyam jakki
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

But i have criteria like that i have id, role, Begin date as Composite Key.
We took the Begin Date as one of the key because for the uniqueness. THe user might have done the mistake of entering the incorrect begin date, and have rectified and wants to change the Begindate. We want to give the user a flexibility to change the begin date and wants to update the record.

Help appreciated ASAP in this regard as it was throwing the error, explained above.

Regards
Shyam
 
Sailesh Ganeshan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi guys,

Please help me out as I'm having similar issue. Let me explain the problem:

I have a CLONE option where, you can create a clone of an existing user details and deactivate the old user. I'm able to clone a new user, but when i try to deactivate the previous use, using his ID, I get the following error -

[ERROR] [org.hibernate.util.JDBCExceptionReporter] - ORA-01861: literal does not match format string

[2010-11-29 09:24:07,839 118368] [ERROR] [org.hibernate.util.JDBCExceptionReporter] - ORA-01861: literal does not match format string

[2010-11-29 09:24:07,841 118370] [ERROR] [org.hibernate.event.def.AbstractFlushingEventListener] - Could not synchronize database state with session
org.hibernate.exception.DataException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic