21.9. Using the Entity Bean

With the entity bean completed and deployed, we need to figure out how to get our application to use it. We can't just change our VersionInfo object to tell the ObjectFactory to create GameEntityBean objects every time we want a new Game for two reasons. One is that we've changed the interface, by adding throws RemoteException to every method, in a fashion that makes our class incompatible as a subclass for Game. Secondly, the container is responsible for the life cycle of EJBs, so even if we didn't have the first problem, we cannot create new EJBs simply by calling new GameEntityBean()—we must instead look up the home interface, and call the create() method it provides.

The solution to both of these problems is the ...

Get J2EE™ and JAX™: Developing Web Applications and Web Services 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.