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.  [ 5 posts ] 
Author Message
 Post subject: increment generator retrying save
PostPosted: Tue Dec 05, 2006 1:59 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
Hibernate version: NHibernate1.2.0Beta

Name and version of the database you are using: SQL Server 2000

The generated SQL (show_sql=true): n/a

I have a table that I'm using an increment generator on for the primary key. Every once in a while two rows get the same key and one gets a primary key exception thrown. When this happens I want to try again with the next available id. When I call Save again nhibernate just reuses the old key which is of course still in use. If I zero out the id nhibernate throws an error saying the id changed. How do I tell nhibernate to grab a new id from the db so I can retry the save?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 3:30 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Don't do this, increment generator was not designed to be used in production. Use identity or guid.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 05, 2006 4:36 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
I really wish I could use either of those others but I can't. It is part of the DBA's requirement, and in their defense they didn't set it up this way. This is how we all have to live with it for now.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 06, 2006 2:12 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
no ideas? How can I just reset the nHibernate's metadata so it doesn't know that I changed the id to 0?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 11, 2006 2:13 pm 
Beginner
Beginner

Joined: Mon Oct 02, 2006 6:46 pm
Posts: 32
anyone have any ideas on this?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.