Results 1 to 4 of 4

Thread: version field added to entities

  1. #1
    Join Date
    Feb 2008
    Posts
    169

    Question version field added to entities

    Why does roo add a "version" Integer column and field to entities? What's this used for?

  2. #2
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    668

    Lightbulb

    It's for optimistic locking. If you attempt to commit some changes to an entity but it turns out someone else has updated that entity in the meantime (as indicated by the version number of your copy no longer matching that in the database), you can abort the transaction or possibly give the user a way of merging their changes with the previous changes. If you've ever used Bugzilla and had a "mid-air collision", this is an example of such a feature.
    Andrew Swan
    "Now is the EJB of our discontent made glorious Spring"

  3. #3
    Join Date
    Feb 2008
    Posts
    169

    Default

    Seems odd that roo forces this on us, my application has no use for this. So the version number is automatically incremented upon every edit?

  4. #4
    Join Date
    Sep 2004
    Location
    Valencia, ES
    Posts
    92

    Default

    You can disable optimistic locking based on "version" field by using @RooEntity as follows:

    @RooEntity(versionField="")
    public class MyEntity {
    ...
    }

    HTH
    Enrique Ruiz
    DiSiD - http://www.disid.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •