The moose likes Object Relational Mapping and the fly likes StaleObjectStateException Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Object Relational Mapping
Reply Bookmark "StaleObjectStateException" Watch "StaleObjectStateException" New topic
Author

StaleObjectStateException

Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
We used Spring/Hibernate in a web application. On the same server, we have some standalone programs that are called manually from some Unix scripts. We just encountered a case when a program was called, and a StaleObjectStateException was thrown:

org.hibernate.event.def.AbstractFlushingEventListener - Could not synchronize database state with session

org.hibernate.StaleObjectStateException: Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect)

I found that the exception occurred in a query. What could be due to it?

Thanks!


SCJP 1.2, SCWCD 1.4
Edmund Yong
Ranch Hand

Joined: Nov 16, 2003
Posts: 164
This option is specified in the HBM file:

select-before-update="true"

I think this could have caused the exception. What I don't understand is that I only do a query, so there is no update involved. Why would the exception occur?
Arun Kumarr
Ranch Hand

Joined: May 16, 2005
Posts: 504

StaleObjectStateException - occurs if the Object - DB tuple state is mismatching. It can be because of two reasons. Either because of some id mismatch or version mismatch.

Can you please post your hbm files and the values of objects in DB?


If you are not laughing at yourself, then you just didn't get the joke.
 
 
subject: StaleObjectStateException
 
Threads others viewed
Hibernate Automatic Versioning
java coding problem ~ system.out.println
Unable to catch StaleObjectStateException. EJB exception doesn't wrap it.
bean properties are coming back null
Hibernate + locking
developer file tools