I am working on a Spring-MVC project in which we are using Hibernate as our ORM and PostgreSQL as the database. We have a Students class, whose ID we are using in one of the PDF form generated, and for business reasons we require that the number be incremented by 1 always. I checked that the allocation-size
parameter can be changed for Hibernate, but does it also effect the underlying sequence in PostgreSQL or do I have to create a new one?
If the underlying sequence is not altered by Hibernate, how can I change the sequence so that it's auto-incremented by 1 in PostgreSQL. Thank you.
Code :
@Id
@Column(name="studentid")
@GeneratedValue(strategy = GenerationType.SEQUENCE,generator = "student_gen")
@SequenceGenerator(name = "student_gen",sequenceName = "student_seq",allocationSize = 1)
private int studentid;