• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate and Spring probs

 
vikrant jain
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
reateBankCustomerClient started
log4j:WARN No appenders could be found for logger (org.springframework.core.CollectionFactory).
log4j:WARN Please initialize the log4j system properly.
Classpath loaded
>>>>>--AFTER ADD ACCOUNTS METHOD COMPLETED---->>>>>
>>>-appContext.getBean.getClass--->>>class springexample.hibernate.CustomerDAOImpl
>>>-customerDAOImpl.getClass()--->>>class springexample.hibernate.CustomerDAOImpl
>>>>>---INSDIE THE TRY BLOCK OF ADDCUSTOMER--->>>>>
Hibernate: update TWC_TBL_ACCOUNT set UPDATE_DATE=?, ACCOUNT_BALANCE=?, CUSTOMER_ID=? where ACCOUNT_ID=?
org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1; nested exception is org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
Caused by: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:61)
at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:46)
at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:24)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2353)
at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(AbstractEntityPersister.java:2257)
at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2557)
at org.hibernate.action.EntityUpdateAction.execute(EntityUpdateAction.java:92)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:248)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:232)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
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 org.springframework.orm.hibernate3.HibernateAccessor.flushIfNecessary(HibernateAccessor.java:388)
at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:363)
at org.springframework.orm.hibernate3.HibernateTemplate.saveOrUpdate(HibernateTemplate.java:676)
at springexample.hibernate.CustomerDAOImpl.addCustomer(CustomerDAOImpl.java:20)
at springexample.hibernate.CreateBankCustomerClient.main(CreateBankCustomerClient.java:45)
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, without any mappings being posted, I have to guess.

My guess is that you are using Optimistic locking and have a version field, and you are trying to update using data that is stale. Meaning someone else has updated the record before that update and incremented the version field to one or more more than the second update. Meaning

update mydata values() where version_field=1;

but in the data table the version_field is already at 2, and therefore the above update statement does not update any record, and when that happens Hibernate will through a StaleStateException.

Or the other thing that could possible have happened is that someone else deleted the record you were going to update, and your Transaction Isolation level is like set to none.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic