EJB 3.0 Development Overview

Table of Contents

  1. Introduction
  2. EJB 3.0 Project Creation
  3. Reverse Engineering Entities and Facades from Databases
  4. Advanced Entity Editing and Validation Tools

1. Introduction

This document presents an overview of EJB 3.0 features available in MyEclipse 6.0.

To get a better feel for MyEclipse and learning more about it, please check out our product Documentation for more material.

2. EJB 3.0 Project Creation

Use the File > EJB Project menu item to invoke the EJB project wizard. Alternatively, you can invoke the EJB project wizard from the New project wizard (File > New > Other).

Figure 2.1. Creating a new EJB 3.0 project

Create an EJB 3.0 project by selecting the Java EE 5.0 - EJB3 radio button. Optionally add persistence support.

Figure 2.2. New EJB Project wizard - Page 1

Specify the runtime JNDI data source and select a MyEclipse database driver and schema for design time support.

Figure 2.3. New EJB Project wizard - Page 2, persistence configuration

You may change the EJB 3.0 project's design time driver association at any time using the Java Persistence properties page. To invoke this page, right click on the project and select Properties from the context menu. From the Properties dialog shown below, expand the MyEclipse node and select Java Persistence.

Figure 2.4. Java Persistence properties page

3. Reverse Engineering Entities and Facades from Databases

Initiate Entity generation from the context menu of an EJB 3.0 project. This will launch the EJB3 Reverse Engineering Wizard.

Figure 3.1. Entity generation from an EJB 3.0 project

Entity generation can also be initiated from the Database Browser view.

Figure 3.2. Entity generation from a DB Table

The reverse engineering process is fully customizable. Using the EJB3 Reverse Engineering Wizard you can choose the artifacts to generate and the database tables from which the artifacts will be based.

Figure 3.3. Select artifacts to be reverse engineered

Following are several sample snippets of the code generated by the Reverse Engineering process.

Figure 3.4. Snippets of generated code

4. Advanced Entity Editing Tools

a) MyEclipse Java Persistence Perspective

Figure 4.1. MyEclipse Java Persistence perspective

b) JPA Details View

The JPA Details view makes it easy to edit entity annotations.

Figure 4.2. JPA Details view - Editing table details
Figure 4.3. JPA Details view - Editing column details

c) JPA Annotation Table and Column Content Assist

Figure 4.4. Table content assist
Figure 4.5. JPA column content assist

d) JPA Entity Validation

Errors in your mapping are detected and displayed in the editor and problems view.

Figure 4.6 Column validation in the Java editor
Figure 4.7 Mapped by validation in the Java editor
Figure 4.8. JPA validation errors shown in Java editor

The JPA Entity Validator can be enabled or disabled at the project level.

Figure 4.9 JPA validation preferences