BMP EJB Classes

The current release includes a beta release of the bean managed persistence EJB generator.

Overview

Bean Managed Persistence enterprise java beans can require a lot of coding. The JDBC Wizard can use database tables or views. In order to generate BMP EJB's a few steps must be taken using the wizard:

  1. Create the bean
  2. Select the columns you would like to select, insert and update
  3. Create finders, if any. The wizard automatically generates findByPrimaryKey(). For additional finder methods (eg findAll(), findByRegion(String theRegion)) the Wizard must be used to specify part of the SQL, and any parameters the finders need.
  4. Select the create() methods to generate. And if the remove() method should delete a database record, or just thorw an exception.

Primary Keys

If the database object does not have a primary key defined, please follow these steps:

  1. Select the column object which is to be a primary key, or part of a composite primary key
  2. Check the Primary Key checkbox
  3. Press Save

Creating A BMP EJB

By drilling down the treeview control, we can reach the "BMP EJB Classes" node below the database table or view of our choice. See below.

When the create button is pressed, the user is navigated to the next set of dialogs.

Configuring BMP EJB's

The BMP EJB Classes tab (shown below), displays java class and manifest information the wizard will generate.

Configuring Columns

The columns tab is used to configure the bean's individual columns, and how they map to the underlying database. The bean must have select and insert access to the primary key column(s).

The columns property editor pops up when an entry in the table is double clicked.

Configuring Finders

The finders tab allows bean finders to be created, edited and removed.

To create a new finder, press the new button.

Below is a sample EJB finder parameter dialog:

Configuring Create Methods

The wizard allows two types of ejb create methods to be generated. For example:

public Person create(PersonDAOData thePersonDAOData)
public Person create(String theEmail, String theFirstName, String theLastName, String theTitle) 

The PersonDAOData class is also generated by the wizard. It is used to hold a bean instance's values.

public class PersonDAOData implements java.io.Serializable
{
   protected Date myDateAdded;
   protected String myEmail;
   protected String myFirstName;
   protected String myLastName;
   protected String myTitle;
   public PersonDAOData() 
   public PersonDAOData(PersonDAOData theToCopy) 
   public void clearProperties() 
   public Date getDateAdded() 
   public String getEmail() 
   public String getFirstName() 
   public String getLastName() 
   public String getTitle() 
   public void setDateAdded(Date theDateAdded) 
   public void setEmail(String theEmail) throws NullPointerException
   public void setFirstName(String theFirstName) 
   public void setLastName(String theLastName) 
   public void setTitle(String theTitle) 
}

 

The tab (shown above) has the following settings:

Configuring The Remove Method

Generating Java Code

The wizard can generate java code, when one or more beans have been created in the wizard.

More information on generating and using the EJB source code can be found here.