The following code only renders an ID of 0
@Id
@GeneratedValue(strategy=GenerationType.AUTO, generator="PROJECT_SEQ_GEN")
@SequenceGenerator(name="PROJECT_SEQ_GEN", sequenceName="X.X_PROJECT_SEQ", allocationSize=1)
private long projectId;
I tried SEQUENCE
and AUTO
but both with the same result. x_project_seq.nextval
works fine in my Oracle database. I would like to keep using the sequence already defined in the database.
According to the Getting Started guide by Spring - Accessing Data with JPA ...
"The Customer’s `id property is annotated with @Id so that JPA will recognize it as the object’s ID. The id property is also annotated with @GeneratedValue to indicate that the ID should be generated automatically."
From their example it looks like all they did was create new Customer
and the IDs were automatically generated. What am I missing here?