-->
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.  [ 2 posts ] 
Author Message
 Post subject: Hibernate 3.5.0-CR-2 causes duplicate primary keys
PostPosted: Thu Feb 25, 2010 6:55 pm 
Newbie

Joined: Thu Feb 25, 2010 6:48 pm
Posts: 2
Hi,

I just updated our builds to use the newly released 3.5.0-CR-2 release and am finding that I get duplicate primary key errors in the database all the time causing rollbacks.

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "rest_request_pkey" at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:1608) at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1343) at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:194) at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:451) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:350) at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:304) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.postgresql.ds.jdbc23.AbstractJdbc23PooledConnection$StatementHandler.invoke(AbstractJdbc23PooledConnection.java:477) at $Proxy47.executeUpdate(Unknown Source) at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:46) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2418) ... 73 more

For our setup we're using Hibernate 3.5.0-CR2, Atomikos JTA, PostgreSQL 8.4.

This is only part of the large trace I was getting. Has anyone else seen this? Is there anywhere I can look/trace for debugging and see whats going on?


Top
 Profile  
 
 Post subject: Re: Hibernate 3.5.0-CR-2 causes duplicate primary keys
PostPosted: Fri Feb 26, 2010 5:04 am 
Expert
Expert

Joined: Tue Jun 16, 2009 3:36 am
Posts: 990
I tested Hibernate 3.5.0-CR2 today with Bitronix JTA, SQLServer2008 and didn't have this problem.
Anyway I suggest you to trace the sql-statements with p6spy for locating the sql-statements which are responsible for the duplicate primary key violation.

N.B.: A common scenario for duplicate key errors is when persisting several new objects before setting their key values.
Rely on the update-actions for differing the keys doesn't work because hibernate first executes all insert actions.


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