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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access