Using oracle/JPA Hibernate. I imported the schema which has values under student table in below fashion. Here is the example
100
85
80
70
1
I have below code:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
long id;
Now when a new student is inserted , it does not inserts max value i.e 101 (max + 1). But inserting some values available in between like 90. I am not sure how its possible ?
Does Hibernate internally create some database sequence and use then use last created value plus 1
For oracle, yes it creates a sequence (probably named
hibernate_sequence).If you have existing values in the table, you probably want to update the sequence to give you ids larger than the existing ones (otherwise you'll soon get primary key errors).