0

I have a progam using hibernate @Version annotation to do optimistic locking.

I want to update a row on the database without doing it via hibernate.

Is it possible to simply increase the value in the column in my DB-Update script and will hibernate then follow the right behavior (throw an exception since the version has changed)?

Xtroce
  • 1,749
  • 3
  • 19
  • 43

1 Answers1

2

Yes, it should be possible to increment the version number externally and hibernate will throw an exception if you try and save with an out of date version number.

If you are not seeing that behaviour, you should look into the "hibernate.jdbc.batch_versioned_data" property in your hibernate configuration.

See Hibernate saves stale data with hibernate.jdbc.batch_versioned_data for more info.

Community
  • 1
  • 1
simonv
  • 99
  • 1
  • 2
  • 6