0 Replies Latest reply on Mar 16, 2005 6:54 AM by Raj Subramani

    JBoss/Hibernate & object versioning

    Raj Subramani Newbie


       public void updateDeal(Deal deal)
       1 session = this.getSession();
       2 session.update(deal);
       4 session.flush();
       5 session.close();

      The above code is my Session Facace operating on a Hibernate bean (Deal).

      I have a

      public Deal getDeal(long dealId)

      function in this Session Facade too.

      If two "clients" A & B were to call the getDeal function and obtain a copy of the same Deal object (and say this Deal instance had version number = 3), via two separate Stateless Session Beans

      if client B were to call updateDeal(deal), via a new Stateless Session Bean

      and then client A were to call updateDeal(deal), again via a new Stateless Session Bean

      then the latter simply goes through, even though client A's version number 3 does not match the current version number for that Deal object (which is 4).

      I though this was precisely the point at which my session facade should have received a StaleObjectStateException.

      At the moment, I am forced to implement an application level version control check (like one would do with CMP's).

      I'm confused and documentation on this is very thin on the ground. Most of the stuff that deals with the above is not in the context of an application server.

      Much appreciate any pointers.