ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Don't Let Hibernate Steal Your Identity
Subject:   Initialize the ID generator from the DB
Date:   2006-09-28 10:16:27
From:   chuckls
Another approach that results in smaller PK IDs is to initialize the IDgenerator from the database when the application starts up by looking for the max id in the table. You can generalize this by using an insert trigger to update a global table with a single record when an id exceeds the current value of the record. Then you can use a single IDgenerator for all objects but you pay the cost of having a trigger on inserts.