3 Replies Latest reply on Apr 1, 2010 4:04 PM by Osian Hughes

    Update Hibernate Objects

    Osian Hughes Newbie

      Hi,


      I have a situation where 2 users are on the same page, one does an update, and now I want those changes reflected in the other users screen, or at least the hibernate objects to be updated with the latest changes.


      Is there an easy way around this?


      Thanks,
      Osian

        • 1. Re: Update Hibernate Objects
          Ilya Dyoshin Novice

          add @Version private Long version; to your Entities. and rely on optimistick locking. If 2 users start editing the same object - the first who changed to the database would automatically update the version of the object - this would lead for other user (who was a bit slower) - to receive exception with optimistick locking, and require to reload the entity object from the database (latest version) for continue.


          regards,


          Ilya Dyoshin

          • 2. Re: Update Hibernate Objects
            Gabor Jakab Newbie

            Use the optimistick locking strategy as Ilya mentioned above, additionally take care to update all caches (session cache and also second level cache if you use it) plus you can use

            <a4j:push reRender="msg" eventProducer="#{messageBean.addListener}" interval="3000"/>

            tag on the specific page to do periodical updates for the other users...

            • 3. Re: Update Hibernate Objects
              Osian Hughes Newbie

              Thanks for your replies, and I do want to end up using the Pesimistic locking mechanism, but haven't found a nice easy example yet :-)


              With regards to the updating of all caches, how do I do this from Seam?


              And I am using Icefaces, so the push server from them will do the same thing for me (I hope).


              Thanks again,
              Osh