-->
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: Duplicate ids problem
PostPosted: Mon Jun 14, 2004 9:23 am 
Newbie

Joined: Fri Jun 04, 2004 8:50 am
Posts: 2
I am working on our project migration from hibernate 1.2 to hibernate 2.1.4. In old mapping files we used <generator class="vm.long"/> I have updated generator to <generator class="increment"/> and now when I try to create a new object ant to save to the database I get:

java.sql.BatchUpdateException: Invalid argument value: Duplicate entry '70979778677178481' for key 1

This id was created by hibernate 1.2 version and the new generator generates duplicate ids.

Does anybody know how to solve the problem ? I do not want to use another id generator (for example identity) because this will involve modification of the database schema (we use mySQL database).

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 14, 2004 12:05 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
consider building you own generator, it'll be the safiest way.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jun 16, 2004 2:01 am 
Newbie

Joined: Fri Jun 04, 2004 8:50 am
Posts: 2
I found what the problem occurs because of mySQL. IncrementGenerator retrieves max id and increments the max id by 1. The problem occurs because mySQL's max function returns an id which does not exist in the database and hibernate generates an id that already exists in the db. I use mySQL version 3.23.49. I have tested my app with mySQL 4.1.1 and the problem disappeared.


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.