• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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?

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
    Bookmark Topic Watch Topic
  • New Topic