User这个Bean不可以是abstract class

解决方案 »

  1.   

    例子中的cmp都是abstract的,这里为什么不可以呢
      

  2.   

    应该是某些CMP字段没有定义SET和GET方法。
      

  3.   

    public abstract class UserBean implements EntityBean {
            private EntityContext ctx;
        Logger logger_ = Logger.getLogger(getClass().getName());    //access methods for cmp fields
        public abstract void setUserName(String userName);
        public abstract String getUserName();
        
        public abstract void setPassword(String password);
        public abstract String getPassword();
        
        public abstract void setPrivilege(String privilege);
        public abstract String getPrivilege();
        
        //ejb required methods, called by container
       // public UserBean() {}
        
        public void ejbActivate() {
            this.logger_.info("ejbActivate() called.");
        }
        
        public void ejbPassivate() {
            this.logger_.info("ejbPassivate() called.");
        }
        
        public void ejbRemove() {
            this.logger_.info("ejbRemove() called.");
        }
        
        public void ejbLoad() {
            this.logger_.info("ejbLoad() called.");
        }
        
        public void ejbStore() {
            this.logger_.info("ejbStore() called.");       
        }
        
        public void setEntityContext(EntityContext ctx) {
            this.logger_.info("setEntityContext() called."); 
            this.ctx = ctx;    
        }
        
        public void unSetEntityContext() {
            this.logger_.info("unSetEntityContext() called."); 
            this.ctx = null;    
        }
        
        public void ejbPostCreate(String userName, String password,
                                  String privilege) 
        throws CreateException{
            this.logger_.info("ejbPostCreate() called."); 
        }
        
        public String ejbCreate(String userName, String password, 
                                String privilege) 
        throws CreateException {
            this.setUserName(userName);
            this.setPassword(password);
            this.setPrivilege(privilege);
            return userName;
        }
    }
      

  4.   

    >>例子中的cmp都是abstract的,这里为什么不可以呢
    EJB规范这么规定的,至少2.1是这样,就是不能用abstract。