• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Optimistic concurrency with hibernate: version not increasing

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
i am developing a web application using spring boot and spring data jpa (hibernate). I implemented optimistic concurrency using the @Version annotation. My domain object has the field "version" (int) and that annotation. Also i added the version to my database. If i create my entity using my frontend it writes the entity successfully to the database with the version 0. Then i am editing my entity using my frontend and submitting the changes. The data are submitted successfully to the database again and the version is 1. Looks good...but now...if i change my entity again (like before) i get an StaleObjectstateException and no data are submitted to the database. Do you have any idea? Of course, if two users are changing the data the StaleObjectstateException is thrown. Thats exactly what i want, but here i am working only with one user and i expect, that one user can always change the data and the version changes.
Cheers
pascal
 
reply
    Bookmark Topic Watch Topic
  • New Topic