hello

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;
  |                             
testSessionC.adjust2Balance(balance.getId(),amount);
  |                     }
  | 

//stateless bean:

  | @Stateless
  | @Remote(TestSessionC.class)
  | @Local(TestSessionC.class)
  | 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();
  |             b.setAmount(old+amount);
  |             em.merge(b);
  |     }
  | 
  | }
  | 

my Balance entity use version control:

  |     @Version
  |     @Column(name = "OPTLOCK")
  |     public int getVersion() {
  |             return version;
  |     }
  | 
  | 

thanks for any ideea

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4066930#4066930

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4066930
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to