Using Hibernate 3.2.2 on Linux version 2.4.21-47.ELsmp Also Weblogic 10.3 Transactions are JTA
I'm baffled by this one.
1. I have a transient object. I introduce it to the Hibernate session using Session.saveOrUpdate(Object).
2. Hibernate reacts by invoking the Oracle sequence that implements the key, and updates the PK of my object, without performing an INSERT. (This surprised me, but okay, I can understand if we're deferring the actual INSERT for flush time, it's just not Hibernate behavior I've experienced as "normal".)
3. But later, when I invoke Session.flush(), Hibernate reacts as if it already has a persistent object -- apparently because of the presence of a PK (again as I would have expected) -- and tries to get the current database snapshot. Of course there isn't one yet, and it responds by throwing a StaleObjectStateException.
So what am I experiencing here? Is it weird that an INSERT was not performed at saveOrUpdate time? What could get Hibernate to perform this pair of mutually inconsistent moves?
|