0 Replies Latest reply on Jan 20, 2006 11:44 AM by Rui Maia

    GeneratedIdTable wrong behaviour?

    Rui Maia Newbie

      Hi all.

      I'm trying to use a GeneratedIdTable generator and I have the follwoing configuration:

      A top level annotation at the beginning of the class:

      @javax.persistence.GeneratedIdTable( name="GENERATOR",
      table=@javax.persistence.Table(name="SEQUENCE_TABLE"),
      pkColumnName="SEQUENCE_ID",
      valueColumnName="SEQUENCE_VALUE")

      public class aClass implements java.io.Serializable {

      ....
      ....
      @Id(generate=GeneratorType.TABLE, generator="aGenerator")
      @TableGenerator(name="aGenerator", tableName="GENERATOR", pkColumnValue="USER", allocationSize=20)

      @Column(name = "USER_ID", unique = true, nullable = false, insertable = true, updatable = true, precision = 22, scale = 0)
      public Long getUSERId() {
      return this.userId;
      }


      In the database I have the SEQUENCE_TABLE table with SEQUENCE_ID and SEUQNCE_VALUE fields. I have a row with the pair of values

      SEQUENCE_ID | SEQUENCE_VALUE
      USER | 100

      so, the next value of the userId field (when I persist a new User) should be 100 and the table columnSEQUENCE_VALUE value with SEQUNCE_ID = 'USER' should pass to 101.

      But what happens is that the value on the table row passes to 101 but the userId field value in the newly created user is somehow random (11201, 1060). Am I doing (or thinking) someting wrong or is this a bug?

      regards

      RM