-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate is assigning an ID but not issuing an INSERT
PostPosted: Fri Apr 06, 2012 4:27 pm 
Newbie

Joined: Fri Apr 06, 2012 4:00 pm
Posts: 1
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.