Iv got this really weird behavior in my hibernate. I'v got a transactional service method, code is below:
And please examine my stacktrace. It does not make any sense:
I dont know exactly why is this so, but the sequence of code execution is quite not sync'd with how i expect it to be.
If you examine my code closely, I wanted to print the version number before save, and then save the record, after that, get the version number after save. The problem is, it's not the sequence here. What happen is this, print version number before save, print version number after save, update record, print version number before save (the value is the same with the previous one), print version number after save (value is the same with the previous one), update record and boom exception occurs.
Base on the stacktrace, why do i have two insert statements (operationLogs) and two update statements (customer table)??? And why does the sequence of execution wont match, and why does after saving/persisting/updating, the retrieved customer does not have the correct version. Im quite sure that the customer i passed as parameter in this method is updated since i retrieved the customer first (fresh from the database) before passing it to this method.
Im so confused guys. I need this system up and running already. Can you please shed me some light?
He does not suffer fools gladly. But this tiny ad does:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop