我與甲骨文序列和Hibernate的一個問題。我用這個代碼來獲得甲骨文序列與HibernateHibernate和甲骨文序列
@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;
}
,但是當我插入一個新值表,生成的值不正確。例如: 當我有數據庫中的兩個記錄與ID 2和3,當我插入新的,它的ID不是4但25。我不知道如何處理它。
使用 '戰略= GenerationType.AUTO' 而不是 '戰略= GenerationType.SEQUENCE'。 – Rajesh
爲什麼要那樣做? (順便說一句,我已經嘗試過,但沒有運氣) – ismail