I just face a problem may be in transaction i dont get latest value. Can any one help me out in.
Exception logged is:
[12/26/06 12:45:44:688 IST] 4318a58d StaleObjectSt E net.sf.hibernate.StaleObjectStateException TRAS0014I: The following exception was logged net.sf.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect) for com.cashtech.iwrbase.transaction.instrument.entity.dao.WireDao instance with identifier: 55640196 at net.sf.hibernate.persister.AbstractEntityPersister.check(AbstractEntityPersister.java:498) at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:715) at net.sf.hibernate.persister.NormalizedEntityPersister.update(NormalizedEntityPersister.java:690) at net.sf.hibernate.impl.ScheduledUpdate.execute(ScheduledUpdate.java:53) at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java(Compiled Code)) at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2260) at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2185) at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:61)
Basically, it means that some other user updated that record and Hibernate knows it. This happens when you have optimistic locking with a version field, so the two users get the data and say it is version #2.
When the first user comes back and update statement is run with version = 2 in the where clause, and it updates the version field to be 3.
So when the second user comes back and tried to run an update statement with version=2 in the where clause, no record will be updated, but Hibernate is smart to see no values are updated and it throws this Exception. This way you cna catch that exception and be nice and send the second user a message that someone else has updated that record before they could do the change and will ahve to reload the data and start again.
In my application i am having concurrnecy issue. If two user hits same funtionality hibernate throws this exception if two user have made request or single user sends more than one request by resubmitting same form some of values duplicate values get inserted in database.
So is that like few times hibernate fails to reconcile with database ?
Thanks & Regards, Abhijit
[ December 26, 2006: Message edited by: abhijit salvithal ]
[ December 27, 2006: Message edited by: abhijit salvithal ] [ December 27, 2006: Message edited by: abhijit salvithal ]