• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What are versioned data ?

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi.
In Hibernate, What are 'versioned data' ?
When to use it ?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its an optimistic locking strategy provided by Hibernate. If you give your mapping a <version /> element, when you try to update an object Hibernate will check whether the value of the version contained in the object matches that held in the database. If they don't match Hibernate throws a StaleObjectException. If they do Hibernate updates the object incrementing the version.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, How to use them ?
Should I supply a value for a versioned field in my code ? or I have to get it by some where ?
Example please !
Thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is optimistic locking something your application needs?

You would add a version field your table, with an integral or date data type and map this field to the <version /> element in your mapping. You don't need to set the value of this Hibernate will do it for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic