Monday, November 06, 2006

BC4J:Understanding EODefImpl class

Most of the time, while creating an EO, we choose the custom EOImpl class to be generated. In the same EO wizard->Java Panel, we have another option of "Create DefImpl class".So whats this?
EODefImpl class, bahaves as the "home" or "factory" for the Entity Object. We can define custom, factory level methods(mostly the validation methods for the entire set of rows in the VO cache and/or in the underlying DB table).

Every EOImpl.java has a method like below..

/**Retrieves the definition object for this instance class.
*/
public static synchronized EntityDefImpl getDefinitionObject() {
if (mDefinitionObject == null) {
mDefinitionObject = (EntityDefImpl)EntityDefImpl.findDefObject("oracle.apps.fusion.schema.server.CustomerEO");
}
return mDefinitionObject;
}

This is where the handle to the Home or factory i.e the DefImpl class is obtained.
How to make use of a user defined DefImpl class method in the base EOImpl.class.

Here is an example
CustomerDefImpl home = (CustomerDefImpl)CustomerImpl.getDefinitionObject();
if(home != null &&
home.existsDuplicateCutomerEmail(this.getDBTransaction(), getCustEmail()))
{
raise JboException;
}

No comments:

Post a Comment