Getting Started with WebSphere Application Server
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
Chapter 5 – Enterprise Java Beans 99<br />
In this step, a JPA project is created <strong>with</strong> eclipse. The JPA project often contains several<br />
entities generated from the database. To make use of the JPA entities, other projects<br />
such as Web projects, and EJB projects often depend on JPA projects. The referenced<br />
JPA project will be deployed <strong>with</strong> the Web project or EJB project together in Community<br />
Edition.<br />
3. Create a database connection in Eclipse<br />
Since the database pool has been created in the Community Edition server, a<br />
connection is needed in Eclipse. With this database connection, the data management<br />
plug-in can get database information to prepare for the generation of JPA entities.<br />
4. Generate JPA entities<br />
JPA can map Java classes to database entities. Once the tables in the database have<br />
been defined, several JPA entities can be generated directly from these tables. In that<br />
way, both EJB project and Web project can make use of the generated entities.<br />
An example using JPAs is provided in the Exercises section of this chapter.<br />
5.5 Summary<br />
This chapter discussed EJB 3.0 related topics <strong>with</strong> Community Edition, including EJB 3.0<br />
development, application client development and JPA entities application in Community<br />
Edition.<br />
5.6 Exercises<br />
In this exercise you will develop an EJB, JPA and a servlet to calculate university credits of<br />
students. You will use Eclipse <strong>with</strong> the WEP installed and DB2 Express-C 9.7. Credits of all<br />
the students will be shown using a servlet.<br />
Note:<br />
The exercise complete code and solutions are provided in the zip file<br />
getting<strong>Started</strong>WithWasceEdition1st_src.zip accompanying this book.<br />
Follow these steps:<br />
1. Create a database and a table in DB2 Express-C 9.7<br />
Follow the steps introduced in Chapter 4.2.1 – Creating a database, to create a<br />
database called Studntdb as shown in Figure 5.3.