Friday 15 March 2013

Modify EJB methods and Finders


1) Open XBonusEJBBean java class, we need to overload ejbCreate(...) method and mention the same in Home interface, also add fullfill(...) and getOwner() methods:


    public com.ibm.commerce.extension.objects.BonusKey ejbCreate(
            long memberId, Integer bonusPoint)
            throws javax.ejb.CreateException {
   
        this.initializeFields();
        _initLinks();
   
        this.memberId = memberId;
        this.bonusPoint = bonusPoint;
   
        XBonusEJBKey aKey = new XBonusEJBKey(memberId);
        this.initializeOptCounter(aKey);
   
        return null;
    }
   
    @Override
    public Long getOwner() throws Exception {
        // TODO Auto-generated method stub
        return memberId;
    }
   
    @Override
    public boolean fulfills(Long member, String relationship) throws Exception {
   
        if("creator".equalsIgnoreCase(relationship)){
            return member.equals(memberId);
        }
        // TODO Auto-generated method stub
        return false;
    }
 


2) Delete below 3 methods:



















3)Add finders to the EJB - > double click on deploymenent descriptor and go to Bean tab (at bottom) and do the following configuration:









Next we need to Generate the EJB to RDB Mapping



No comments:

Post a Comment