employeeejb.java

来自「java EJB 编程源代码。」· Java 代码 · 共 71 行

JAVA
71
字号
package enroll.welfareejb;

import java.util.*;
import javax.ejb.*;

public class EmployeeEJB implements EntityBean
  {
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
   //这是一个基于Entity Bean的Bean Class,这个Entity Bean是基于
   //Container-managed Persistence的Entity Bean,用来对EmployeeTBL表进行操作
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   public String employee_id;
   public String name; 
   private EntityContext context;
  
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  
   //定义回调方法(CallBack Methods)
   //- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

   public void setEntityContext(EntityContext context)
     {
      this.context = context;
     }
   
   public void unsetEntityContext()
     { 
      context = null;
     }

   public String ejbCreate(String employee_id, String name) throws DuplicateKeyException, CreateException
     {
      this.employee_id = employee_id;
      this.name = name;
      return null;
     }
   
   public void ejbPostCreate(String employee_id, String name)
     {}
  
   public void setName(String name)
     {
      this.name = name;
     }

   public String getName()
     {
      return name;
     }
  
   public void ejbLoad()
     {}

   public void ejbStore()
     {}

   public void ejbActivate()
     { 
      employee_id = (String)context.getPrimaryKey();
     }

   public void ejbPassivate()
     {
      employee_id = null;
      name = null;
     }

   public void ejbRemove()
     {}
  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?