EJB design mode 3

zhaozj2021-02-11  199

Design mode 3

In design mode 2 we see, between Entity Bean and Struct

There are many duplicate code, such as the same field declaration (corresponding to the table columns in the database).

If you let the Entity Bean inherited from the structure to avoid redundant code. but

This design still cannot display the connection between Beans.

Code Snippet for Company Entity Bean

Public Class CompanyBean Extends CompanyStruct

Implements EntityBean {

EntityContext EntityContext;

// All Fields in CompanyStruct Are Available for CMP

Public Integer Ejbcreate (Companystruct Struct)

Throws createException {

this.comid = Struct.comID; // SET The PRIMARY Key

SetData (STRUCT); // This Removes Some Redundant Code

Return NULL;

}

The rest of the code, such as the implementation and design mode of GetData () and setData () methods 2

It is exactly the same.

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

New Post(0)