Chapter 11. Sample application 253
Figure 11-8 New look of the DB Servers pane
11.2 MVC model with entity Beans and a session Bean
In the scenario we build several types of entity Beans, even for the same table. Two types of
entity Beans are available—container-managed Persistence (CMP) and Bean-managed
persistence (BMP). Both can work with JDBC and SQLJ. For the model component, we have
the following types:
򐂰 CMP/JDBC Beans for the three tables (EMP, DEPT, EMP_PHOTO_RESUME)
11.2.1 Creating entity CMP Beans using JDBC from the imported tables
When creating Enterprise JavaBeans using WSAD, they have to reside in an EJB project. In
this section we generate container-managed Persistence (CMP) Beans that use JDBC for our
three tables that we imported in the previous section.
Creation of an EJB project
Based on the imported tables, we create an EJB project ItsoEJB1 in WSAD, in which we will
generate the container-managed persistence entity Beans (CMP).
Left-click New in left top corner of your WSAD work space (Figure 11-9).
Figure 11-9 New button
A pop-up (Figure 11-10 on page 254) shows up with the project/type selections.
254 DB2 for z/OS and WebSphere: The Perfect Couple
Figure 11-10 Project selections
We select EJB in the left column, and EJB project in the right column. Click Next.
A window like Figure 11-11 shows up next.
Figure 11-11 EJB level specification
Indicate an EJB2.0 project and click Next. EJB 2.0 types are new with WAS V5 and J2EE 1.3.
Enter the name ItsoEJB1 as the EJB project name (Figure 11-12), and do not forget to also
enter a name for the Enterprise Application (EA) this project is part of. We choose the name
Itso1EAR, as all ingredients of J2EE projects finally are packaged in an Enterprise Archive
(EAR) and deployed via this file in the WebSphere containers. It is not required to create a
client EJB project in our scenario.
Figure 11-12 Project name and Enterprise Application
Finally, click Finish, and the two projects (ItsoEJB1 and Itso1EAR) are created.
Chapter 11. Sample application 255
Importing the tables into a folder of the EJB project
Look for a DB Servers view in the Data or J2EE perspective. Find the connection (DBD8T4)
corresponding with the imported tables in WSAD, and put focus on the three tables that have
been imported, as shown in Figure 11-13
Figure 11-13 Import to folder in EJB project
Right-click Import to Folder.
In the new window (Figure 11-14) that shows up, we have to indicate the project/folder in
which the tables have to be imported.
Figure 11-14 Select of the import folder
Click the Browse button. This allows us (in a new pop-up) to navigate to the project/folder
EjbModule under the ItsoEJB1 project. After clicking OK the Folder selection line is filled in,
and we click Finish. The system will ask a few times for the creation authorization of new
subfolders. Those should be confirmed, and finally after a while the ItsoEJB1 project looks
like Figure 11-15 on page 256 (in the Data Definition window of the Data perspective).
256 DB2 for z/OS and WebSphere: The Perfect Couple
Figure 11-15 EJB project after import
In the project tree we notice the additional sub folders that have been created
In the J2EE perspective, in the top left Project Navigator view, under the sub folder
META-INF/backends/DB2UDBOS390_v7_1, we find metafiles *.tblxmi for the three imported
tables. These files will be the sources for the Entity EJB’s mapping. The “backends” notion
indicates already that we can have tables from several backends in the same EJB project.
Before we can do the mapping, we will have a look at those files and verify that all required
ingredients are present. One important requirement is that each table, which will be mapped
to an entity Bean, must have a
primary key. We can open the *.tblxmi files with the table
editor. We start with the NULLID.DEPT table. Double-clicking the file NULLID_DEPT.tblxmi
opens up a first pane (see Figure 11-16 on page 257), which is the overview pane. At the
bottom, we have a menu with thumbnails that allows us to walk through different panes. All
this information has been picked up from the metadata imported from DB2 into the project.
Note: The usage of the DB2UDBOS390_v7_1 directory may be confusing. We indeed
work with a DB2 V8 system, but the DB2 V8 labeling was not yet supported in WSAD V5.1
at the time of writing.

Get DB2 for z/OS and WebSphere: The Perfect Couple 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.