-->
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.  [ 3 posts ] 
Author Message
 Post subject: Creating objects with identity column inserts before flush
PostPosted: Tue Jan 31, 2006 5:18 pm 
Beginner
Beginner

Joined: Sat Apr 17, 2004 1:11 am
Posts: 36
We've realized today that when saving new instances of some of our mapped classes that are mapped with identity columns are inserted immediately before calling flush on the session. Is this behavior considered correct as the docs seem to indicate that nothing goes to the DB until you flush and especially if your FlushMode is Never.

We want to use long running sessions as discussed in HIA but this issue could be a problem as we're working with a legacy DB and it might be difficult to change the tables to not use an identity column.

Is there a workaround that will keep the inserts from happening until flush is called for identity columns? I can't find anything about it in the ML archives or forum archives.

Thanks...

benster


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 31, 2006 5:29 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes it is correct, NHibernate has to return an identifier for the object when Save is called and for identity generated id's there is no other way but to go ahead and insert the object immediately. There is no workaround that I know of.

http://www.hibernate.org/hib_docs/reference/en/html/manipulatingdata.html#manipulatingdata-flushing


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 31, 2006 6:18 pm 
Beginner
Beginner

Joined: Sat Apr 17, 2004 1:11 am
Posts: 36
Thanks for the reply, Sergey - I assume this won't be helped by moving to a H3.X codebase.

Yech.

benster


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

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.