-->
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: Using sequence generator
PostPosted: Thu Oct 14, 2010 3:08 am 
Newbie

Joined: Thu Oct 14, 2010 3:01 am
Posts: 3
Hi,
I am trying to create a sequence as a primary key. The issue is that instead of incrementing by 1, it gets incremented by 50, though I have not specified that number anywhere. I tried in both derby and oracle. But the same result. So, I feel the problem could be with my code. Please help.

Code:

@Entity
@Table(name = "PERSON")
@SequenceGenerator(name = "Person_Id_Sequence", initialValue = 1, sequenceName = "Person_Id_Sequence")

public class Person {
   private String firstName;
   private String lastName;
   private Integer personId;
   private Timestamp lastUpdated;

   protected Person() {

   }

   public Person(PersonVO personVO) {
      this.setFirstName(personVO.getFirstName());
      populateAttributes(personVO);
   }

   public void populateAttributes(PersonVO personVO) {
      this.setLastName(personVO.getLastName());
   }

   @Column(name = "FIRST_NAME", nullable = true, length = 35)
   public String getFirstName() {
      return firstName;
   }

   public void setFirstName(String firstName) {
      this.firstName = firstName;
   }

   @Column(name = "LAST_NAME", nullable = true, length = 35)
   public String getLastName() {
      return lastName;
   }

   public void setLastName(String lastName) {
      this.lastName = lastName;
   }
   @Id
   //@GeneratedValue(strategy = GenerationType.AUTO, generator = "Person_Id_Sequence")
   @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "Person_Id_Sequence")
   @Column(name = "PER_ID")
   public Integer getPersonId() {
      return personId;
   }

   public void setPersonId(Integer personId) {
      this.personId = personId;
   }

   @Version
   @Column(name = "LAST_UPDATED")
   public Timestamp getLastUpdated() {
      return lastUpdated;
   }

   public void setLastUpdated(Timestamp lastUpdated) {
      this.lastUpdated = lastUpdated;
   }
}


and my hibernate.cfg.xml has the following entries

Code:
<hibernate-configuration>
   <session-factory>
      <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
         <property name="connection.driver_class">oracle.jdbc.OracleDriver</property>
         <property name="connection.url">jdbc:oracle:thin:@N7553:1521:ORCL </property>
      <property name="connection.username">ips</property>
      <property name="connection.password">ips</property>
      <property name="hibernate.current_session_context_class">org.hibernate.context.ThreadLocalSessionContext</property>

      <property name="hibernate.show_sql">true</property>
      <property name="hibernate.format_sql">true</property>

      <!-- Mapping classes -->
      <mapping class="Person" />
   </session-factory>

</hibernate-configuration>



Top
 Profile  
 
 Post subject: Re: Using sequence generator
PostPosted: Mon Aug 29, 2011 7:37 pm 
Newbie

Joined: Mon Aug 29, 2011 7:30 pm
Posts: 1
If I am not mistaken, the increment. size is a function. Of the way the sequence. Was created
Take a look at the create. Sequence. Instruction.


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.