Hibernate and Spring probs
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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)
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)
posted 18 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
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
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
| The glass is neither half full or half empty. It is too big. But this tiny ad is just right: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |








