-->
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.  [ 4 posts ] 
Author Message
 Post subject: Duplicate entry error when inserting a new record
PostPosted: Thu Mar 11, 2004 10:11 am 
Newbie

Joined: Sun Dec 07, 2003 8:33 pm
Posts: 5
Hi,

I'm using Hibernate 2.1.1 with Mysql 3.23. I'm trying to autogenerate id's which are of type long.

When I try to insert a new record, I get the message:
java.sql.SQLException: Invalid argument value, message from server: "Duplicate entry '0' for key 1"

Here's the relevant portion of the mapping fille:
<id
name="id"
column="ID"
type="java.lang.Long"
>
<generator class="native">
</generator>
</id>

Here's the Java code which fails:
Transaction trans = session.beginTransaction();
p = new PersonImpl();
p.setName1( "aa" );
p.setName2( "bb" );
session.saveOrUpdate( p );
trans.commit();

I have ensured that the id attribute in the PersonImpl object is indeed null when it goes into saveOrUpdate.

Thanks in advance for any hints.

Michael


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 10:24 am 
Newbie

Joined: Sun Dec 07, 2003 8:33 pm
Posts: 5
Never mind: I found the problem...

thanks
MD


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 05, 2004 6:27 pm 
Newbie

Joined: Mon Apr 05, 2004 6:25 pm
Posts: 5
Hi damaru:

I met the same problem as you did. Can you tell me your solution?

Thanks much!

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 22, 2004 6:32 pm 
Newbie

Joined: Sat Mar 27, 2004 2:43 pm
Posts: 5
Yes, please, what was the problem ?


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