-->
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: Key increment issue
PostPosted: Thu Jul 31, 2008 8:22 am 
Newbie

Joined: Thu Jul 31, 2008 8:14 am
Posts: 3
Location: Faisalabad
hi
I have two methods that save data in same table of database using hibernate + spring...Primary key is auto-generated and has increment as generator..However i am getting a very strange result..When i save an object using first method,object gets persisted let's say at primary key value 45.Now i save some objects using other methods in same table lets say at primary key values 46,47,48.Now when i get back to saving some object with first method i get an exception saying duplicate value for key '46'.I try again and get same exception but saying duplicate value for key '47' and then for 48 and finally object gets persisted.....SO ANY IDEA WHAT SHOULD I DO? i am using declarative transaction management......


HELP is greatly appreciated....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 12:24 pm 
Newbie

Joined: Thu Jul 31, 2008 10:51 am
Posts: 3
Location: Wuppertal, Germany
hmm, did I get you correct that you're mixing auto-generation and using a generator?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 31, 2008 5:06 pm 
Expert
Expert

Joined: Wed Mar 03, 2004 6:35 am
Posts: 1240
Location: Lund, Sweden
The increment generator assumes that no other is inserting into the database at the same time. The documentation says ...when no other process is inserting data... but I guess this applies to any non-Hibernate inserts in the same process as well. You should probably use the identity generator instead.


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.