Reputation: 59
Lets say i have a spring + hibernate application which works fine together. One table A is managed by the application(CRUD). And there might be other programs which also insert some data into the table A. So here comes the problem.
For example: hibernate points the next id to 1001(auto_increment) and before it receives any data, i use a jar file to insert 100 records into the mysql db. So the next id to insert should be 1101 at the point. But if now hibernate receives a record and tries to insert, it throws a exception: java.sql.BatchUpdateException: Duplicate entry '1001' for key 'PRIMARY'. Could you please help? Thanks in advance!
ps: in hbm.xml:
<id name="cns_id" column="cns_id" type="long" access="field">
<generator class="increment" />
</id>
Upvotes: 1
Views: 166