-->
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.  [ 1 post ] 
Author Message
 Post subject: Hibernate issue with Oracle Sequence
PostPosted: Tue Apr 23, 2013 6:41 am 
Newbie

Joined: Wed Nov 28, 2012 7:37 am
Posts: 4
Hi,

I hope I am posting to the correct forum!

I have successfully used a Spring/Hibernate web-based application to insert records into an Oracle database. The Oracle database table that I am writing records to is fairly straightforward - but it is important to know that the first column of the table needs to be populated with the value supplied by a dedicated Oracle Sequence. The problem that I am having is that Hibernate DOES NOT ALWAYS seem to use the value of the Oracle Sequence.

Here is some code, which illustrates the steps I have taken to try to resolve this issue myself:

Code:
@Entity
@SequenceGenerator(name="audit_seq", sequenceName="MARTINI_STORE.STY_SOR_ID_SEQUENCE", allocationSize=1, initialValue= 1)
@Table(name="MARTINI_STORE.STY_ORDER_RETRY_PAYMENT")
public class STYOrderRetryPayment implements Serializable {
   /**
    * Serializable class - generated UID
    */
   private static final long serialVersionUID = 4396053457149921483L;
   
   @Id
   @GeneratedValue(strategy=GenerationType.AUTO, generator="audit_seq")
   @Column(name="SOR_ID", nullable=false)
   private long sorId;

        //other fields and getters/setters omitted


The code above shows a snippet from the bean I use to persist data to the table. The field sorId is mapped to the column on the database table that should be populated with the value supplied by the dedicated Oracle Sequence.

What I have noticed is that stopping and starting the servlet container (Tomcat 6x) can sometimes cause the a value to get inserted into the column that does not match the next available value from the dedicated Oracle Sequence.

I have tried searching for answers to this issue, but have not come up with anything so far...

I look forward to hearing from you.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.