6. Binding the EJB to the JDBC data source.

EJB mapping approaches review

All of the EJB to relational mapping capabilities previously available in VisualAge for Java are now also available in Websphere Application Developer, although some techniques require a slightly different approach. As before, there are three different mechanisms:

￿Top down: The developer creates the CMP entity beans in the application, and the database schema and mapping are generated from this definition.

￿Bottom up: An existing database schema exists for the application, which is imported into the development environment, and used to generate the CMP entity beans and the mappings.

￿Meet in the middle: This scenario is useful when there is a requirement to map a series of new or existing entity beans into an existing database schema.

For simplicity, we are using the top down approach, where we create the entity bean, and use it to create the database schema and table definition.

Preparing to create the entity EJB

Websphere Studio Application Developer provides a wizard that facilitates the creation of the entity EJB. Before we start using that wizard, we must perform an important step.

Project configuration

Make sure that you create CustomerInfoEJB project and it is EJB 1.1 complient. Switching to the J2EE perspective, and in particular J2EE view. The CustomerInfoEJB project should appear attached to the node EJB modules.

Creating the entity EJB

To create the entity EJB using the top down approach, we do the following:

Under the EJB Modules category in the J2EE perspective, select the CustomerInfo project, right-click, and select New—>Enterprise Bean.

The wizard for creating the Enterprise bean opens Figure 10-17. To create the bean do the following:

1.Select Entity Bean with container-manages persistence (CMP) fields. Enter the bean name as Customer, and the package name as registration.

2.Click Next.

Chapter 10. Development of XML-based Enterprise applications 239

Page 255
Image 255
IBM Version 5 manual EJB mapping approaches review, Preparing to create the entity EJB, Project configuration