Author | Message |
---|---|
plakhan
Posts: 37
|
Posted 15:19 Feb 07, 2015 |
We add table to the database using the create sql, then we insert the data. My question is how does hibernate sequence will now that there is already data in the table, so that it can bring the next value. For eg, I have already added 2 plans in the database. So when i try to add a new plan from the application, how will hibernate sequence identify to add the new plan from id=3, since i have to plan already in the database. Reason am asking is this because, i get a primary key error when i try to insert new plan from the application. |
cysun
Posts: 2935
|
Posted 15:27 Feb 07, 2015 |
A sequence has nothing to do with values that are already in a table. To avoid conflicts, you can create a sequence with a minvalue. For example:
The sequence then will only generate values starting from 1000, e.g. 1000, 1001, .... If you use IDs that are less than 1000 for the pre-created records, there won't be any conflicts. |