Following is what my data structure is: I have a table A that has information in multiple related tables. Any changes to the this table A or the related tables needs to be recorded. To store and track the completion of the processes the updates are recorded in a table U.
Problem Description: Recently I added a trigger to the table U which would make some calculations based on the new data in A and the related tables. The problems is, when hibernate batches updates, it has a particular order in which the "insert", "update" and "delete" statements are run. Inserts are happening before the updates causing an unexpected situation. An insert in U for an update in A happens before the actual update in A happens. This causes the trigger I have written to work on the new data in A to actually works on the old data.
Possible Solution: After the update to A call the flush method before the insert to U.
Question: Has anyone else come across such a problem and implemented a better solution than this?
|