Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate optimistic-lock="true" not working

 
Pramod Shivale
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have made optimistic-lock="dirty" dynamic-update="true" for the entity in mapping file.

And the code to test this is:


I am excepting StaleObjectStateException but this code runs without any exception.
please provide some suggestions or code to test this.
[ November 25, 2008: Message edited by: Paul Sturrock ]
 
Pramod Shivale
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
same probelm with optimistic-lock="all"
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am excepting StaleObjectStateException but this code runs without any exception.

Why are you expecting this? All your code runs in one transaction (though you do nest another in there), so I wouldn't expect any updates to be made to the database (and hence, no version checking) until the second tx.commit().

Try testing it with two clients, ratehr than one client doing two operations.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic