-->
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 key error when using sequence generator
PostPosted: Mon Nov 01, 2004 2:33 pm 
Newbie

Joined: Wed Dec 10, 2003 10:08 am
Posts: 2
I hit a couple duplicate key exceptions that have me stumped. My application creates rows in a message_queue table and uses an Oracle sequence number to auto-generate the key. I am using Hibernate's sequence generator. This is the first time I have ever seen this problem. It is running in a weblogic 8 environment. I looked at my logs and I could not see any other clients accessing the DB at that time so it was not related to that. I searched the forum and other avenues without success. Anybody have any clue as to what might cause this. This should not happen.

Thanks,
Pat

Hibernate version:
2.1.2

Mapping documents:
<id
name="msgId"
type="long"
column="MSG_ID"
>
<generator class="sequence">
<param name="sequence">MESSAGE_QUEUE_SEQ</param>
</generator>
</id>

Code between sessionFactory.openSession() and session.close():
MessageQueue msgQ = new MessageQueue();
msgQ.setMsgRecipient("aaa");
msgQ.setMsgType("type");
msgQ.setMsgText("test");
msgQ.setMsg("msg");
session.save(msgQ);
session.flush();

Full stack trace of any exception that occurs:
Caused by: weblogic.jdbc.base.BaseBatchUpdateException: [BEA][Oracle JDBC Driver][Oracle]ORA-00001: unique constraint (FDR.MESSAGE_QUEUE_PK) violated
at weblogic.jdbc.base.BasePreparedStatement.executeOneStatementAtATime()[I(Unknown Source)
at weblogic.jdbc.base.BaseStatement.executeBatchEmulation(Ljava.util.Vector;)[I(Unknown Source)
at weblogic.jdbc.base.BasePreparedStatement.executeBatch()[I(Unknown Source)
at weblogic.jdbc.wrapper.PreparedStatement_weblogic_jdbc_base_BasePreparedStatement.executeBatch()[I(Unknown Source)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(Ljava.sql.PreparedStatement;)V(BatchingBatcher.java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch()V(BatcherImpl.java:118)
at net.sf.hibernate.impl.SessionImpl.executeAll(Ljava.util.List;)V(SessionImpl.java:2306)
at net.sf.hibernate.impl.SessionImpl.execute()V(SessionImpl.java:2256)
at net.sf.hibernate.impl.SessionImpl.flush()V(SessionImpl.java:2182)
at com.xerox.hc.messaging.session.MessageManagerSessionBean.setMessages([Lcom.xerox.hc.messaging.common.MessageHolder;)[Ljava.lang.Long;(MessageManagerSessionBean.java:107)

Name and version of the database you are using:
Oracle 9

The generated SQL (show_sql=true):
Production run so no debug available

Debug level Hibernate log excerpt:
Production run so no debug available


Top
 Profile  
 
 Post subject: oracle sequence unique constraint error
PostPosted: Wed Nov 02, 2005 9:10 pm 
Newbie

Joined: Wed Nov 02, 2005 9:03 pm
Posts: 1
Location: Natick, MA
Did you manage to resolve this issue? I am getting a similar issue that you described buy my db is Oracle RAC. Any help will be greatly helpful. Thanks.

_________________
Mani G. Iyer


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 7:19 am 
Newbie

Joined: Mon Dec 19, 2005 6:58 am
Posts: 3
And, solved?

We have a similar problem...

_________________
Bernd Rücker
camunda GmbH


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 19, 2005 9:38 am 
Newbie

Joined: Mon Dec 19, 2005 6:58 am
Posts: 3
OK, I think I have found a solution, that seems to work.

configure the Interval & Cache-Size of the oracle-sequence ("HIBERNATE_SEQUENCE" per default) to the same size.

For example

Code:
ALTER SEQUENCE "BERND"."HIBERNATE_SEQUENCE" CACHE 50 NOMAXVALUE INCREMENT BY 50

_________________
Bernd Rücker
camunda GmbH


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.