Creating a new EJB composer

A composer class is used to map a single complex bean field to multiple database columns. This composition is needed for complex fields that are themselves objects with fields and behavior.

Consider the following example: In your CustomerBean CMP entity bean, you have an attribute called CustomerAddress. The type of the CustomerAddress attribute is a complex type that you defined in a class called Address.class, which contains multiple Java fields: street, city, and zip. In order to map the complex CustomerAddress type to different columns in a table, you need a new composer class that defines which fields in the composed type class (Address.class) map to which columns in the database. The composer class composes the Address.class making it possible for you to map the CustomerAddress attribute in CustomerBean.

Use the New Composer wizard to add a new composer definition to your type list. After you create the new composer definition, you can use the composer class in the Mapping editor.

Restrictions and notes:

To create a new composer definition:

  1. In the J2EE perspective, select File > New > Other > EJB > Converter or Composer, then click Next.

  2. Select the Composer radio button.

  3. Type or select an EJB project.

  4. Type a fully qualified composer name.

  5. Type or select a fully qualified supertype.

  6. Type or select a fully qualified target type.

  7. Add or select the New composed field type. You must select more than one composed field type.

  8. Additionally, you can Remove a selected field.

  9. Optional: Select the Generate a composer stub class check box to generate a new composer class template for the new composer definition. The composer stub class that is generated is not complete. It is up to you to define the dataFrom and objectFrom methods.

  10. Click Finish. When you open the Mapping editor, the composer name that you defined appears in the Outline view.