Adding the Implementation of the ejbCreate Method

When implementing the method ejbCreate, the only thing you need to take into account is the data needed to create a new table record.In this case, all the parameters passed when the ejbCreate method is called must be passed to the associated CMP fields of the entity bean. You will implement this using the corresponding set methods. The EJB container then takes over the task of saving the record in the table.


You have created the entity bean QuickBookingBean.

The structure of your project QuickCarRentalEjb is currently displayed in the J2EE Explorer.


  1. In the project structure, expand the QuickCarRentalEjb ® ejb-jar.xml node and double-click the name QuickBookingBean.

An editor appears, in which you can navigate to any of the bean’s components.

  1. Choose Navigate to Bean Class.

The Java Source Editor opens and displays the generated source code of the bean class.

  1. Navigate to the implementation of the method ejbCreate.

The Outline view allows you to navigate quickly and easily. To navigate to the implementation of the method ejbCreate, simply click the method name in the Outline view.

  1. Add the following code after // TODO : Implement:









  1. If necessary, correct the formatting of these lines by choosing Source ® Format from the context menu.
  2. Save the contents of the editor by choosing the appropriate icon from the toolbar.


You have added calls of the set methods to the method ejbCreate of the bean class. The passed values can now be assigned to the associated CMP fields of the bean.

Next step:

Implementing the Business Logic