• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Frits Walraven
  • Joe Ess
  • salvin francis

Wierd behaviour. Hibernate optimistic locking error

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello guys,

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?

Thanks,
-marckun
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
Sauce Labs - World's Largest Continuous Testing Cloud for Websites and Mobile Apps
https://coderanch.com/t/722574/Sauce-Labs-World-Largest-Continuous
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!