First page Back Continue Last page Graphics
findByPrimaryKey( )
findByPrimaryKey( )
- Described explicitly in EJB spec
- Looks up entity by primary key, returns remote bean type
FinderException
- Finder throws javax.ejb.FinderException:
- Defines all failures to find request objects
Home can have other find*( ) methods
- To locate single entities or sets
- Not covered in this course...
Notes:
The EJB spec describes find*( ) methods to be defined in the home interface. These do not exist for session beans; they are unique to entity beans. They are used to locate an existing bean instance (in reality, to create a bean instance from existing data). In container-managed persistence, these methods are implemented automatically by the container. They all have this syntax:
findByPrimaryKey( ) is described explicitly in the spec. Obviously it looks up an entity by its primary key value and returns an instance of the remote bean type.
For example, the BeanHome interface would have the method shown above.
This method throws a javax.ejb.FinderException. This is a checked exception that defines all failures to find request objects.