Working with EJBs

WebLogic Builder generates descriptors and interfaces for a bean class only if the bean class follows the naming convention of ending in either "Bean" or "EJB."

See the following sections for information about EJBs.

 


Creating a Relationship Between 2.0 CMP Beans

Create a relationship between two 2.0 CMP beans using the following procedure.

  1. In the navigational tree under the EJB node, right-click the Relations node and select Add a relation... Note that if your module does not have CMP beans, WebLogic Builder will not display the Relations node.

  2. In the Relations dialog, enter or select a name for the relation.
     
     
     

  3. Set the Between option to One or Many for the first bean, and select the bean.

  4. Set the And option for the second bean to the desired match with the first bean's Between option, and select the second bean and click Next.

  5. In the second Relations dialog, select a Role name, a CMR (Container Managed Relationship) field for the second bean, and a primary key Field for the first bean and a column for the second bean.
     
     
     

  6. Click Next.

  7. In the third Relations dialog, select the role name and optionally set bidirectional relations (CMR field and field type).
     
     
     

  8. Click Finish.

    WebLogic Builder writes the relation to ejb-jar.xml, and an entry for the relation appears in the Relations node.

 


Adding a CMP Field to an Entity Bean

Add a Container Managed Persistence field to an entity bean using the following procedure.

  1. In the navigational tree under EJB, expand an entity bean node and select the CMP Fields node.

  2. In the CMP Fields dialog, select the field's name, which will correspond to a getter on your Bean class. For example, if you have getFirstName() on your Bean class, the name of the CMP field will be firstName.

  3. Use the browse button to browse to a table name. If you are not connected to a server, the browse button will activate the Connect to a Server dialog.

  4. To select the column name, click the browse button and browse the table. Select a column and click OK.

  5. Set the column type.

  6. Click OK.

    The new CMP field will appear in the navigational tree under the CMP node of the bean.

 


Adding a Finder Method to an EJB

To add a finder method to a bean, use the following procedure.

  1. In the navigational tree, under the name of your entity bean, expand the bean and select Finders.

  2. In the bean's Finder editing panel, click Add.
     
     
     

  3. Select the method name, enter its properties, and click OK.

 


Specifying Optimistic Concurrency

You may want to set optimistic concurrency for your CMP entity beans when parallel transactions seem unlikely to conflict or when speed of response times is more important than certainty that transactions have not conflicted. WebLogic Builder's default setting is pessimistic concurrency. To set optimistic concurrency, do the following.

  1. With an entity bean selected in the left navigational panel, select Tuning -> Cache. In the Concurrency strategy selection field, select Optimistic.

    A dialog offers to let you select the Verify column and the Optimistic column to map the entity bean to a table.


     

  2. Select Version or Timestamp in the Verify column to enable the Optimistic column field.

  3. You can use the Browse button to connect to a server, browse a database, and select a column, or you can type the column name directly.

 


Adding an ejb-reference Between Two Beans

  1. In the navigation tree, expand an EJB and select Resources.

  2. In the EJB's Resources editing panel, select the EJB Refs or the EJB Local Refs tab and click Add.

 

back to top