I was developing a spring-hibernate app which worked well till I chose to migrate to SQL Server to import some data easily
The problem is after importing (the ID column was filled by numbers till 18,000), when I try to add another row to my database, hibernate generates ID beginning from 1 (I used Auto, Table, Sequence, and Identity)
Is there a solution for this problem ?
Or should I import the data starting from a big value for ID column ?
Thanks in advance.
You can use something like this:
@Entity
@SequenceGenerator(name="seq", initialValue=18000, allocationSize=100)
public class EntityWithSequenceId {
@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="seq")
@Id long id;
}