The approach I would take would be to first define the sequence in the database (let's call it "FOO"), then set its next value to be higher than the maximum value of any record in the table for that field.
Then, I would change the *.hbm.xml file for that table to use the sequence generator as follows:
The approach I would take would be to first define the sequence in the database (let's call it "FOO"), then set its next value to be higher than the maximum value of any record in the table for that field.
Then, I would change the *.hbm.xml file for that table to use the sequence generator as follows:
<class name="com.this.is.my.Classname">
<id name="fieldThatRepresentsPrimaryKey">
<generator class="sequence">
<param name="sequence">FOO</param>
</generator>
</id>
...
and that would be about it!