Set the Default values for Entity Object
Ex, Set the HireDate for Employee as System Date
Approach 1: Override the create() method of EntityImpl
Generate EmployeesImpl.java class of EmployeesEO Entity Object
/**
* Add attribute defaulting logic in this method.
* @param attributeList list of attribute names/values to initialize the row
*/
protected void create(AttributeList attributeList) {
super.create(attributeList);
this.setHireDate((Date)Date.getCurrentDate());
}
Approach 2: Override the create() method of EntityImpl
Generate EmployeesImpl.java class of EmployeesEO Entity Object
Replace the existing code in getHireDate() with the following:
Date hireDate = (Date)getAttributeInternal(HIREDATE);
// check for null and return today's date if needed
return (hireDate == null) ? (Date)Date.getCurrentDate() :
hireDate;