Deal All:
   I have a sesseion bean like this:
public @Stateless class InventoryMgrBean implements 
InventoryMgrLocal,InventoryMgrRemote {
private static Object lock=new Object();
--------------------------------
public  NEKey findByNEPK(NEPK nePK) {           
NEKey neKey=null;
try{
Query q=em.createQuery("select n from NEKey n where n.wwn=:WWN");
q.setParameter("WWN",nePK._wwn);
neKey=(NEKey)q.getSingleResult();
}catch(NoResultException e){
return null;
}
return neKey;
}       
-----------------------------
public NEKey createNEKey(NEPK nePK) {
try {
synchronized (lock) {
NEKey neKey = findByNEPK(nePK);
if (neKey == null) {
neKey = new NEKey();
neKey.setWwn(nePK.get_wwn());
neKey.setIpAddresses(nePK.get_ipAddresses());
neKey.setName(nePK.get_name());
em.persist(neKey);
}
return neKey;
}
} catch (Exception e) {
e.printStackTrace();
return null;
}
                
}
    When multiple-thread try to invoke this createNEKey() method.Exception(JDBC 
batch update fail) will be thrown at em.persist(neKey).Class NEKey is entity 
bean with ID auto-generated.
     Can anyone give some advice?
     Great Thanks!
Kingofhawks

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

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3950020


_______________________________________________
JBoss-user mailing list
JBoss-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jboss-user

Reply via email to