So far, we have discussed only the simple-case entity beans in which a single entity bean is mapped to a single database table. No book on EJB 3.0 is complete without a discussion of relationships between multiple entity beans with each bean mapped to a different database table. Multiple entity beans and multiple database tables become essential when it is not feasible to define all the entities in a single entity bean and a single database table. In this chapter, we shall discuss an example of multiple entity beans with relationships between them. We shall learn the following:
Creating database tables
Mapping the database tables to entity classes
Creating a wrapper session bean
Creating a client JSP for the entity bean application
Testing the client
Demonstrating the effect of modifying the fetch strategy
But, first we shall review the different metadata annotations provided for EJB 3.0 entity relationships.