Creating the Implementation Class
There is very little that needs to be done by application developers to create a basic business
entity. In addition to the setup of the CI_MD_* tables describing the entity and its
constraints, only an implementation class (or Impl
) needs to be added.
In this case, a developer added Person_Impl
. The following is a simple
example of an Impl
class for the Person
entity.
/**
* @BusinessEntity
* (tableName = CI_PER,
* oneToManyCollections = { @Child( collectionName = names,
* childTableName = CI_PER_NAME,
* orderByColumnNames = { SEQ_NUM } )
* }
* )
*/
public class Person_Impl
extends Person_Gen {
/**
* @return the UI Display "info" for this person
*/
public String getInfo() {
return "PrimaryName: " + getPrimaryName().getInfo();
}
}
Important parts of the implementation class are described below:
-
The implementation class name must end with the suffix
_Impl
. For example, if the entity has aperson
name, then the implementation class name would besome.package.Person_Impl
. This also means that the generated business interface will be named assome.package.Person
. -
A Class Annotation which declares:
- What table this entity represents.
- What the owned-child tables are and what they should be called.
- Other information. Please see the
BusinessEntityAnnotation
class for more details.
-
The class extends an abstract superclass having the suffix of
_Gen
. Continuing the example of an entity with aperson
name, the implementation class would extend a not-yet-created abstract superclass namedsome.package.Person_Gen
. This superclass is created by the artifact generator based on metadata about the table and contains:- Getter methods for properties, including parent objects and collections.
- The
getDTO()
andsetDTO(...)
methods that allow for properties to be changed. - Access to standard framework methods like
createQuery(...)
.
-
Business methods. Any hand-coded public methods are automatically exported
onto the generated business interface (for example,
some.package.Person
). Client code can then access the added business method as follows:
Person aPerson = some logic retrieving a person instance
String thePersonsInfo = aPerson.getInfo();
- Constants. Any hand-coded public static final variables are automatically exported onto the generated business interface. This will be useful for constants related to the entity.
- Having created a new entity, it is likely that validation rules and other behaviors should be added to it. See Adding Change Handlers for more information.