Automatic Primary Key Generation Sample

This sample shows a CMP entity bean that uses a named sequence table to auto-generate primary keys. For more information on the various methods available to auto-generate primary keys, see Automatic Primary Key Generation.

Concepts Demonstrated by this Sample

Location of Sample Files

The code of the CMP entity bean is located in the automaticPK folder of the EJBs project in the SamplesApp sample application. In the file system the location is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs\automaticPK\Customer_APK.ejb

The web service that you run as a client application to test the EJB, and the EJB control that you use to locate and reference the EJB, are located in the automaticPK folder of the EJBs_ClientApps project in the SamplesApp sample application. In the file system the location of the web service is:

BEA_HOME\weblogic81\samples\workshop\SamplesApp\EJBs_ClientApps\automaticPK\CustomerControlTest.jws

To Run the Sample

  1. Start WebLogic Server in the appropriate domain.
  1. Launch the test web service either by opening it in WebLogic Workshop and selecting the Start operation or by entering http://localhost:7001/EJBs_ClientApps/automaticPK/CustomerControlTest.jws in the address bar of your browser. If WebLogic Server is running in the appropriate domain on this machine, you may click here to run the sample.
  2. Navigate to the Test Form tab of Test View, if necessary.
  3. Invoke the startTestDrive method to create a new conversational instance.
  4. Click continue this conversation.
  5. Locate the create section, enter a first and last name, and click create. Notice that the EJB's create method is invoked via the EJB control.
  6. Click continue this conversation.
  7. Locate and click getCustomer_ID. Notice that the primary key value for the newly created entity bean is returned.

Related Topics

Automatic Primary Key Generation

How Do I: Test an Enterprise JavaBean?

Test View