Entity Bean Common Scenarios

A standard scenario for using an entity bean is for the client to act as follows:

1.
Call the javax.rmi.PortableRemoteObject.narrow(…) method to get a reference to the Home interface.
2.
Any home or finder method can be called at this point. If you are trying to access existing data, the finder method will pass you back the Remote interface for the EJB instance you want. In this case, the desired instance would automatically be created for you by the application server, so the next step would be skipped.
3.
If the instance you require is for new data you are planning to add to the database, using the Home interface reference, call the desired create method for the entity bean. Both the ejbCreate and ejbPostCreate ...

Get Developing Enterprise Java Applications with J2EE™ and UML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.