Sun ONE logo     Previous      Contents      Index      Next     
Sun ONE Web Services Platform Developer Edition Developer's Guide



Parts Supplier Sample Application

This section is an overview describing how to build and deploy related CMP entity beans for the Sun™ ONE Application Server.

Overview

This example demonstrates the use of Enterprise JavaBeans™ entity beans to model database tables with one-to-many relationships.

Two entity beans model two tables with a one-to-many relationship.

The container-managed relationship (CMR) features cascading deletes, so that deleting a part automatically deletes all of the suppliers associated with the part.

The two entity beans are in a server-side application named PartSupplierApp.

This application also contains a session bean.

Clients call session bean methods named getData and insertData, and the session bean calls methods of the entity beans.

In addition to the enterprise beans, the application contains two detail classes. These classes have fields that match the fields of the entity beans. When the session bean is ready to pass records to the clients, it copies field values from the entity beans to instances of the detail classes. It returns these to the client. This is more efficient that returning entity bean remote references.

The example also includes a J2EE™ application client that calls the session bean's methods to insert and then select data.

A diagram of the PartSuppliers Sample Architecture Overview is shown in the following figure.

  
This screen capture shows a diagram of group modules into J2EE application.
PartSuppliers Sample Architecture Overview

The sample architecture illustrated in the figure above is the integration of Sun ONE Studio 4.1 and Sun ONE Application Server 7.0. The integration is demonstrated by developing an application consisting of Container Managed beans in the Sun ONE Studio and deploying it on Sun ONE Application Server.

The integration between the two products is achieved by installing the Sun ONE Application Server Plugin in the Sun ONE Studio. There is a plug-in for each application server that is supported by the Sun ONE Studio.

The PointBase Server is used as a database server in this sample. However, any other relational database with proper JDBC drivers can be used.

The database server contains two tables:

  • Parts table
  • Suppliers table

In this sample two entity beans are created based on these tables. In addition a session bean is created to manage the interaction between the client and the entity beans. Two additional SupplierDetails are created to provide accessor methods of the bean. This application is deployed on the Application Server using the Application Server plug-in. The application also includes a J2EE test client which is used to test the application.


Previous      Contents      Index      Next     
Copyright 2003 Sun Microsystems, Inc. All rights reserved.