1 Reply Latest reply on Apr 30, 2008 5:39 AM by Adam Warski

    FAQ? optimistic locking by version and versioning

    Elias Ross Master

      I guess you'd think that now that the database stores revision data that you'd be able to take advantage of Hibernate optimistic locking for every @Versioned entity.

      Thinking this over, I realize this is not the case. Envars won't check to see that the revision wasn't concurrently changed between the time the entity was loaded and persisted. Which is sort of different than how tools like Subversion work, which does both revision tracking and optimistic concurrency control.

      And so really @Versioned and @Version mean two different things. Maybe Envars should allow (as an extension) the @Version field to be the revision number would be nice. But really I don't think you should need a separate column in a table if there's already a revisions table with its own version.

        • 1. Re: FAQ? optimistic locking by version and versioning
          Adam Warski Master


          yes, @Versioned and @Version do mean different things. I don't think Envers needs to check for concurrent modifications, as this is handled well by Hibernate (either by optimistic or pessimistic locking).

          I don't know if the version-checking mechanism in hibernate is pluggable, but anyway, I think it's a good idea to add an option to replace the default mechanism with a versions-table checking one. Another thing to add to the "todo" list :)