不通过会话bean,直接调实体bean的方法也行???
就好像在一个EJB中调的一样??

解决方案 »

  1.   

    参考http://home.itdrp.com/ansonsoft/shoppingdoc/
    我 写的 文档
      

  2.   

    通过JNDI应该可以实现~ 不过我没有试过:)
      

  3.   

    但是调用同一个包的实体bean时,需要引用这个bean,那我调另一个包的bean时,如何引用呢???
      

  4.   

    请看这段代码
    EJB 会话 bean 包装 EJB 实体 bean import java.rmi.RemoteException;
     import java.security.Identity;
     import java.util.Properties;
     import javax.ejb.*;
     import com.ibm.uxo.bestpractices.datamodels.*; public class EmployeeRosterBean implements SessionBean {
        private EmployeeHome employeeHome;
        private javax.ejb.SessionContext mySessionCtx = null;
        final static long serialVersionUID = 3206093459760846163L;    public void ejbCreate() throws javax.ejb.CreateException,
        java.rmi.RemoteException {
            employeeHome = EmployeeEjbHomeCacheHelper.getEmployeeHome()}    public EmployeeStruct getEmployeeInfoFor(String empno) {
            Employee theEmployee = null;
            EmployeeStructure returnValue = new EmployeeStructure();        try {
                theEmployee = employeeFindByPrimaryKey(new EmployeeKey(empno));            returnValue.setSex(theEmployee.getSex());
                returnValue.setSalary(theEmployee.getSalary());
                returnValue.setPhoneno(theEmployee.getPhoneno());
                returnValue.setMidinit(theEmployee.getMidinit());
                returnValue.setLastname(theEmployee.getLastname());
                returnValue.setJob(theEmployee.getJob());
                returnValue.setHiredate(theEmployee.getHiredate());
                returnValue.setFirstnme(theEmployee.getFirstnme());
                returnValue.setEmpno(empno);
                returnValue.setEdlevel(theEmployee.getEdlevel());
                returnValue.setComm(theEmployee.getComm());
                returnValue.setBonus(theEmployee.getBonus());
                returnValue.setBirthdate(theEmployee.getBirthdate());
                returnValue.setWorkDept(theEmployee.getWorkdept());
            } catch (Exception e) {
                e.printStackTrace();
            }
            return returnValue;
        }    public void ejbActivate() throws java.rmi.RemoteException {}
        public void ejbPassivate() throws java.rmi.RemoteException {}
        public voide ejbRemove() throws java.rmi.RemoteException {}
     }