EJB design mode 1

zhaozj2021-02-11  166

Design mode 1

The first design pattern is very simple. Entity Bean with a company and employee and

The code segment of the Entity Bean given below is similar. They are from JBuilder4

EntityBean template is generated. All fields are declared as public CMP fields.

Code Snippet for Company Entity Bean

Public class companyBean imports entitybean {

EntityContext EntityContext;

Public Integer Comid; // The Primary Key

Public String COMNAME; // The Company Name

Public String Comdescription // Basic Description

Public TimeStamp MutationDate // Explained Later

Public Integer Ejbcreate () THROWS

CreateException {

Return NULL;

}

// various get () and set () for every column / field

// Which Aree Exposed in The Remote Interface As Well

Code Snippet for Employee Entity Bean

Public Class Employeebean Implements EntityBean {

EntityContext EntityContext;

Public Integer Empid; // The Primary Key

Public Integer Comid; // The Company Foreign Key

Public String EmpfirstName; // The Employee Firstname

Public String Emplastname // The Employee Lastname

Public TimeStamp MutationDate // Explained Later

Public Integer Ejbcreate () THROWS

CreateException {

Return NULL;

}

// various get () and set () for every column / field

// Which Aree Exposed in The Remote Interface As Well

Although this design pattern is very simple, there are many shortcomings, such as each one.

The access of the field will result in a remote call to the GET () and set () methods. Far away

Process call (RPCS) is very resource-consuming, and is in actual

Access to the combination of frequent requirements can lead to a series of remote calls. It can be said that this model

The style is very useful in practice. The design pattern shown above can be used as other design

The basis of the pattern, such as RAD, prototype design, test, etc. At this time, that represents

The Employee Entity Bean did not show anything between employees and companies

relationship.

转载请注明原文地址:https://www.9cbs.com/read-5289.html

New Post(0)