com.ibm.websphere.samples.ejbquery.employeefinderejb
Class EmpBean

java.lang.Object
  extended by com.ibm.websphere.samples.ejbquery.employeefinderejb.EmpBean
All Implemented Interfaces:
java.io.Serializable, javax.ejb.EnterpriseBean, javax.ejb.EntityBean

public abstract class EmpBean
extends java.lang.Object
implements javax.ejb.EntityBean

The EmpBean CMP EJB Bean implements the EntityBean interface. It contains the accessor and business methods necessary to work with an Emp. In addition, it contains the Home Interface Methods, and Callback Methods.

See Also:
Serialized Form

Field Summary
protected  javax.ejb.EntityContext entityContext
           
 
Constructor Summary
EmpBean()
           
 
Method Summary
 int add1()
          add1 method returns empid + 1.
 double calcBonus(double profitFactor)
          calcBonus method calculates an employee's annual bonus given a positive profitFactor.
 void ejbActivate()
          ejbActivate required callback method for lifecycle notification.
 EmpKey ejbCreate(java.lang.Integer empid)
          ejbCreate method responsible for the creation of a skeleton Emp.
 EmpKey ejbCreate(java.lang.Integer empid, java.lang.String name, double salary, double bonus, java.sql.Date hireDate, java.sql.Time hireTime, java.sql.Timestamp hireTimestamp, boolean isManager)
          ejbCreate method responsible for the creation of an Emp.
 void ejbLoad()
          ejbLoad required callback method gets called after the EJB is loaded from the database.
 void ejbPassivate()
          ejbPassivate required callback method for lifecycle notification.
 void ejbPostCreate(EmpKey key)
          ejbPostCreate Home Interface Method responsible for post creation steps, there are none for Emp.
 void ejbPostCreate(java.lang.Integer empid)
          ejbPostCreate method responsible for the post creation of a skeleton Emp.
 void ejbPostCreate(java.lang.Integer empid, java.lang.String name, double salary, double bonus, java.sql.Date hireDate, java.sql.Time hireTime, java.sql.Timestamp hireTimestamp, boolean isManager)
          ejbPostCreate method responsible for the post creation of an Emp.
 void ejbRemove()
          ejbRemove required callback method for Contaimer Managed Persistence.
 void ejbStore()
          ejbStore required callback method for Contaimer Managed Persistence.
abstract  double getBonus()
          This abstract CMP field accessor method gets the bonus attribute.
abstract  DeptLocal getDept()
          This abstract CMR field accessor method gets the dept attribute.
abstract  java.lang.Integer getEmpid()
          This abstract CMP field accessor method gets the empid attribute.
abstract  java.sql.Date getHireDate()
          This abstract CMP field accessor method gets the hireDate attribute.
abstract  java.sql.Time getHireTime()
          This abstract CMP field accessor method gets the hireTime attribute.
abstract  java.sql.Timestamp getHireTimestamp()
          This abstract CMP field accessor method gets the hireTimestamp attribute.
abstract  boolean getIsManager()
          This abstract CMP field accessor method gets the isManager attribute.
abstract  java.lang.String getName()
          This abstract CMP field accessor method gets the name attribute.
abstract  double getSalary()
          This abstract CMP field accessor method gets the salary attribute.
abstract  void setBonus(double bonus)
          This abstract CMP field accessor method sets the bonus attribute.
abstract  void setDept(DeptLocal newDept)
          This abstract CMR field accessor method sets the dept attribute.
abstract  void setEmpid(java.lang.Integer empid)
          This abstract CMP field accessor method sets the empid attribute.
 void setEntityContext(javax.ejb.EntityContext ctx)
          setEntityContext required callback method for Container Managed Persistence.
abstract  void setHireDate(java.sql.Date hireDate)
          This abstract CMP field accessor method sets the hireDate attribute.
abstract  void setHireTime(java.sql.Time hireTime)
          This abstract CMP field accessor method sets the hireTime attribute.
abstract  void setHireTimestamp(java.sql.Timestamp hireTimestamp)
          This abstract CMP field accessor method sets the hireTimestamp attribute.
abstract  void setIsManager(boolean isManager)
          This abstract CMP field accessor method sets the isManager attribute.
abstract  void setName(java.lang.String name)
          This abstract CMP field accessor method sets the name attribute.
abstract  void setSalary(double salary)
          This abstract CMP field accessor method sets the salary attribute.
 void unsetEntityContext()
          unsetEntityContext required callback method for Container Managed Persistence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entityContext

protected javax.ejb.EntityContext entityContext
Constructor Detail

EmpBean

public EmpBean()
Method Detail

getEmpid

public abstract java.lang.Integer getEmpid()
This abstract CMP field accessor method gets the empid attribute.

Returns:
java.lang.Integer

setEmpid

public abstract void setEmpid(java.lang.Integer empid)
This abstract CMP field accessor method sets the empid attribute.

Parameters:
empid - java.lang.Integer

getName

public abstract java.lang.String getName()
This abstract CMP field accessor method gets the name attribute.

Returns:
java.lang.String

setName

public abstract void setName(java.lang.String name)
This abstract CMP field accessor method sets the name attribute.

Parameters:
name - java.lang.String

getSalary

public abstract double getSalary()
This abstract CMP field accessor method gets the salary attribute.

Returns:
double

setSalary

public abstract void setSalary(double salary)
This abstract CMP field accessor method sets the salary attribute.

Parameters:
salary - double

getBonus

public abstract double getBonus()
This abstract CMP field accessor method gets the bonus attribute.

Returns:
double

setBonus

public abstract void setBonus(double bonus)
This abstract CMP field accessor method sets the bonus attribute.

Parameters:
bonus - double

getHireDate

public abstract java.sql.Date getHireDate()
This abstract CMP field accessor method gets the hireDate attribute.

Returns:
java.sql.Date

setHireDate

public abstract void setHireDate(java.sql.Date hireDate)
This abstract CMP field accessor method sets the hireDate attribute.

Parameters:
hireDate - java.sql.Date

getHireTime

public abstract java.sql.Time getHireTime()
This abstract CMP field accessor method gets the hireTime attribute.

Returns:
java.sql.Time

setHireTime

public abstract void setHireTime(java.sql.Time hireTime)
This abstract CMP field accessor method sets the hireTime attribute.

Parameters:
hireTime - java.sql.Time

getHireTimestamp

public abstract java.sql.Timestamp getHireTimestamp()
This abstract CMP field accessor method gets the hireTimestamp attribute.

Returns:
java.sql.Timestamp

setHireTimestamp

public abstract void setHireTimestamp(java.sql.Timestamp hireTimestamp)
This abstract CMP field accessor method sets the hireTimestamp attribute.

Parameters:
hireTimestamp - java.sql.Timestamp

getIsManager

public abstract boolean getIsManager()
This abstract CMP field accessor method gets the isManager attribute.

Returns:
boolean

setIsManager

public abstract void setIsManager(boolean isManager)
This abstract CMP field accessor method sets the isManager attribute.

Parameters:
isManager - boolean

getDept

public abstract DeptLocal getDept()
This abstract CMR field accessor method gets the dept attribute.

Returns:
DeptLocal

setDept

public abstract void setDept(DeptLocal newDept)
This abstract CMR field accessor method sets the dept attribute.

Parameters:
newDept - DeptLocal

add1

public int add1()
add1 method returns empid + 1.

eg. select e.add1() from EmpBean e
WARNING.  For methods to work, the server's "Application classloader policy" must be set to "Single". The default is "Multiple" which can be reset using the Administrative Console.

Returns:
int

calcBonus

public double calcBonus(double profitFactor)
calcBonus method calculates an employee's annual bonus given a positive profitFactor.
For non managers this is calculated by multiplying the yearsWorked, the profitFactor, and the profitUnit.
For managers, the previous result is further multiplied by the mgrFactor if the profitFactor is greater than 0.1.
In the method, profitUnit is fixed at 1000 and mgrFactor at 2.

eg. select e.calcBonus(0.2) from EmpBean e
WARNING.  For methods to work, the server's "Application classloader policy" must be set to "Single". The default is "Multiple" which can be reset using the Administrative Console.

Parameters:
profitFactor - the fractional increase of the value of the company during the current the year
Returns:
double

ejbCreate

public EmpKey ejbCreate(java.lang.Integer empid)
                 throws javax.ejb.CreateException
ejbCreate method responsible for the creation of a skeleton Emp.

Parameters:
empid - java.lang.Integer
Returns:
EmpKey the Primary Key Object for Emp, it must be unique.
Throws:
javax.ejb.CreateException - This exception is thrown to indicate a failure to create the entity EJB.

ejbCreate

public EmpKey ejbCreate(java.lang.Integer empid,
                        java.lang.String name,
                        double salary,
                        double bonus,
                        java.sql.Date hireDate,
                        java.sql.Time hireTime,
                        java.sql.Timestamp hireTimestamp,
                        boolean isManager)
                 throws javax.ejb.CreateException
ejbCreate method responsible for the creation of an Emp.

Parameters:
empid - java.lang.Integer
name - java.lang.String
salary - double
bonus - double
hireDate - java.sql.Date
hireTime - java.sql.Time
hireTimestamp - java.sql.Timestamp
isManager - boolean
Returns:
EmpKey the Primary Key Object for Emp, it must be unique.
Throws:
javax.ejb.CreateException - This exception is thrown to indicate a failure to create the entity EJB.

ejbPostCreate

public void ejbPostCreate(java.lang.Integer empid)
                   throws javax.ejb.CreateException
ejbPostCreate method responsible for the post creation of a skeleton Emp.

Parameters:
empid - java.lang.Integer
Throws:
javax.ejb.CreateException - This exception is thrown to indicate a failure to post create the entity EJB.

ejbPostCreate

public void ejbPostCreate(java.lang.Integer empid,
                          java.lang.String name,
                          double salary,
                          double bonus,
                          java.sql.Date hireDate,
                          java.sql.Time hireTime,
                          java.sql.Timestamp hireTimestamp,
                          boolean isManager)
                   throws javax.ejb.CreateException
ejbPostCreate method responsible for the post creation of an Emp.

Parameters:
empid - java.lang.Integer
name - java.lang.String
salary - double
bonus - double
hireDate - java.sql.Date
hireTime - java.sql.Time
hireTimestamp - java.sql.Timestamp
isManager - boolean
Throws:
javax.ejb.CreateException - This exception is thrown to indicate a failure to post create the entity EJB.

ejbPostCreate

public void ejbPostCreate(EmpKey key)
                   throws javax.ejb.CreateException
ejbPostCreate Home Interface Method responsible for post creation steps, there are none for Emp.

Parameters:
key - EmpKey
Throws:
javax.ejb.CreateException - This exception is thrown to indicate a failure to post create the entity EJB.

setEntityContext

public void setEntityContext(javax.ejb.EntityContext ctx)
                      throws javax.ejb.EJBException
setEntityContext required callback method for Container Managed Persistence.

Specified by:
setEntityContext in interface javax.ejb.EntityBean
Parameters:
ctx - javax.ejb.EntityContext
Throws:
javax.ejb.EJBException - This exception is thrown to indicate a failure to create the entity EJB.

unsetEntityContext

public void unsetEntityContext()
                        throws javax.ejb.EJBException
unsetEntityContext required callback method for Container Managed Persistence.

Specified by:
unsetEntityContext in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.

ejbLoad

public void ejbLoad()
             throws javax.ejb.EJBException
ejbLoad required callback method gets called after the EJB is loaded from the database.

Specified by:
ejbLoad in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.

ejbStore

public void ejbStore()
              throws javax.ejb.EJBException
ejbStore required callback method for Contaimer Managed Persistence.

Specified by:
ejbStore in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.

ejbRemove

public void ejbRemove()
               throws javax.ejb.EJBException,
                      javax.ejb.RemoveException
ejbRemove required callback method for Contaimer Managed Persistence.

Specified by:
ejbRemove in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.
javax.ejb.RemoveException - Signals that a Remove exception can occur.

ejbActivate

public void ejbActivate()
                 throws javax.ejb.EJBException
ejbActivate required callback method for lifecycle notification. No actions need to be taken for Emp.

Specified by:
ejbActivate in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.

ejbPassivate

public void ejbPassivate()
                  throws javax.ejb.EJBException
ejbPassivate required callback method for lifecycle notification. No actions need to be taken for Emp.

Specified by:
ejbPassivate in interface javax.ejb.EntityBean
Throws:
javax.ejb.EJBException - Signals that an EJB exception can occur.