Joined: Tue Nov 22, 2005 10:08 am Posts: 17
|
How to override sequence generator with explicit value?
I use sequence generator
<id name="id" column="person_id">
<generator class="sequence">
<param name="sequence">person_id_sequence</param>
</generator>
</id>
In rare cases I need to set the id value explicitly. If I set the id then during save() hibernate thinks that object is already in db and falls over on trying to update row rather than insert.
What's the easiest way to override the id?
I guess I can just use assigned generator, then if I need to save new object I have to ask a sequence for next value and set it on object straight in my code. But that's not really clean and I have to always remember to grab the next sequence value and set it on object before saving...
Are there any other solutions? Do I have to write new generator?
|
|