0 Replies Latest reply on Jul 24, 2007 5:41 AM by serj f

    how to safe update

    serj f Newbie


      I want to know what settings should have for safe updates using stateless beans (if it is possible), when have concurrency. I try to test using this code:

      //this code is from Runnable objects (I have many objects of this type):

       for(int i=0;i<UPDATE_NO;i++){
       int amount = ran.nextInt(1000);
       amountSum +=amount;

      //stateless bean:
      public class TestSessionCBean implements TestSessionC{
       @PersistenceContext(unitName = "...")
       EntityManager em;
       public void adjust2Balance(long id, int amount) {
       Balance b = em.find(Balance.class, id);
       em.lock(b, LockModeType.WRITE);
       float old = b.getAmount();

      my Balance entity use version control:
       @Column(name = "OPTLOCK")
       public int getVersion() {
       return version;

      thanks for any ideea