persistence@glassfish.java.net

initialValue doesn't work in sequence

From: Krzysztof Adamczyk <k.adamczyk_at_merge.com.pl>
Date: Fri, 7 Sep 2007 15:38:28 +0200

Hi,

I have the following problem:
An entity has a primary key generated with a sequence.
I need to have this sequence initialized to the value of 10000.
The following code doesn't work. My sequence starts with 1 :(
What's more, the sequenceName seems to have no effect.
TopLink creates sequence with a different name.
What am I doing wrong? Is this a bug?
I will appreciate any help.


@Entity
@Table(name = "expense_contr_contractors")
@SequenceGenerator(name = "expense_contractor_sequence", sequenceName =
"contr_seq" , initialValue = 10000, allocationSize = 1)
public class ExpenseContractor extends ModelObject implements Serializable {

 private long id;

 @Id
 @Column(name = "contr_id", nullable = false)
 @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "expense_contractor_sequence")
 public long getId() {
  return id;
 }

 public void setId(final long id) {
  this.id = id;
 }
}


Greetings,
Chris