aspose file tools*
The moose likes Object Relational Mapping and the fly likes Hibernate and Spring probs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate and Spring probs" Watch "Hibernate and Spring probs" New topic
Author

Hibernate and Spring probs

vikrant jain
Greenhorn

Joined: Jul 06, 2004
Posts: 1
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

Joined: Feb 05, 2001
Posts: 17257
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate and Spring probs