I have a problem with Oracle sequence and Hibernate. I used this code to get Oracle Sequence with hibernate
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "student_id_seq")
@SequenceGenerator(name = "student_id_seq", sequenceName = "Student_seq")
@Column(name = "StudentID")
public Long getStudentId() {
return this.studentId;
}
public void setStudentId(Long studentId) {
this.studentId = studentId;
}
but when i insert a new value to the table, the generated value is incorrect. For example: when I had two records in database with id 2 and 3, and when I inserted new one, it's id was not 4 but 25. I have no idea what to do with it.