Finding an Entity Object by Primary Key
To find an entity object by primary key, follow these basic steps:
1. Find the entity definition: Obtain the entity definition object for the OrderEO entity by passing its fully qualified name to the static findDefObject() method on the oracle.jbo.server.EntityDefImpl class, a Java class that implements the entity definition for each entity object.
2. Construct a key: Build a Key object containing the primary key attribute that you want to look up. In this case, you’re creating a key containing the single orderId value passed into the method as an argument.
3. Find the entity object using the key: Use the entity definition’s findByPrimaryKey() method to find the entity object by key, passing in the current transaction object, which you can obtain from the application module by using its getDBTransaction() method. The concrete class that represents an entity object row is the oracle.jbo.server.EntityImpl class.
4. Return some of its data to the caller: You use the getAttribute() method of EntityImpl to return the value of the ShipToName attribute to the caller.