Use the below
process/code to find the Entity instance based on the primary key.
- Get the EntityDefinition object by using the EntityImpl class.
- Use createPrimaryKey() method available in the EntityImpl to create the key.
- Use the EntityDefImpl object findyByPrimaryKey method and pass the key you created in the previous step.
- The findByPrimaryKey method gives the EntityImpl, which is an representation of row.
In this example we are considering the
EmployeeEO and empId as primary key.
Private
EmployeeEOImpl findEmpById(String empId){
EntityDefImpl
empDef= EmployeeEOImpl.getDefinitionObject();//Finding the Defintion
Key empKey=
EmployeeEOImpl.createPrimaryKey(new Integer(empId));//Creating the Key
Return
(EmployeeEOImpl) empDef.findByPrimaryKey(getDBTransaction(),empKey);
}
No comments:
Post a Comment