Monday 25 March 2013

Tips to invoke EJB

1)
        xbonusEJBAccessBean.setBonusPoint(totalBonusPoints);
        try {
            xbonusEJBAccessBean.commitCopyHelper();
        } catch (Exception e) {
            e.printStackTrace();
        }
 
OR


      xbonusEJBAccessBean = new XBonusEJBAccessBean(new Long(getFoundUserId()));

Tip: You do not need to call commitCopyHelper() if you create the record using only the constructor, and do not call additional setters.


 2)
bonusAccessBean = new XBonusEJBAccessBean();
bonusAccessBean.setInitKey_memberId(new Long("111"));
bonusAccessBean.refreshCopyHelper();

Use the refreshCopyHelper method to retrieve information from the database and populate the access bean. You do not need to use the refreshCopyHelper() if you are using a getter method to retrieve specific data from the access bean. You only need to use it to explicitly tell the access bean to populate itself, for example, to check if the data you are looking for exists, or to populate an object before passing it to another method.

Note: When instantiating an access bean, you must ensure that all fields set by a setInitKey_xxx method are initialized before retrieving any data from the access bean. 

No comments:

Post a Comment