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

What is the name of hibernate 2 exception?

 
John Landon
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the name of hibernate 2 exception that will be thrown when same field in the same row is being updated by 2 pieces of code simultaneously?

Thanks,
John
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a StaleObjectException.

The scenario you use is not accurate though. Two seperate processes cannot update the same row concurrently, database transacitons prevent this. However, data about a row held by a client can be updated by another process if the data is held outside a transaction. e.g. :

Process 1 Transaction 1: read data.
Process 2 Transaction 1: read data.
Process 2 Transaction 2: write data.
Process 1 Transaction 2: write data.

Assuming you are using versioning in Hibernate the above scenario will cause a StaleObjectException.

Process 1 Transacation 1: read data. Write data.
Process 2 Transacation 1: read data. Write data.

This scenario will not cause a StaleObjectException, since Process 2 cannot update the dame row concurrently (the database prevents it). Instead the updates happen sequentially and no exception occurs.
 
John Landon
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic