I have a requirement to have a last updated time and a creation time placed into the db upon insert or update.
I have triggers in the database that manage the update and creation time and I wanted to tell Hibernate to re-read the values after a create/update operation. So I used the generated="always"
This seems to work sometimes. The straightforward case of update of the object I am saving seems to do the right thing, but if the object is updated in another session due to an operation of a parent object then it doesn't seem to work. The SQL generated seems fine but it just doesn't re-read the times into the object.
Example:
Object A has collection of ObjectB.
Object B was saved in another session.
Then we add B to A's collection and that causes B to change ( we set the id of A into B)
When the transaction finishes, A is committed and B is committed and lastupdate time of B is re-read but not into the object !
Any ideas what could cause this problem?
|