I am afraid this is not possible. Because id field is the identifier of your entity. If there is a change in the identifier field then it semantically means that the entity is different from the previous one.
You wont be able to do an update of the primary key field of an existing row. But what you can do is have the generator for your id field as "assigned" and assign the primary key value you want. If you want to update the key field of an existing row, then create a new entity from the existing entity, may be with a clone and then assign whatever id value you want. Delete the existing entity and save the cloned, changed entity.
Now if I were in your place, what I would do is, have an additional generated key field in ur table and make that one the id field for hibernate. Now whatever is the current id field, make it a unique non-null field.
_________________ Regards, Litty Preeth
|