Browse Prior Art Database

Generic Entity EJB SQL wrapper and code generator

IP.com Disclosure Number: IPCOM000021706D
Original Publication Date: 2004-Feb-04
Included in the Prior Art Database: 2004-Feb-04
Document File: 4 page(s) / 121K

Publishing Venue

IBM

Abstract

Enterprise JavaBeans (EJBs) are designed to reduce development time for enterprise applications, but it is possible to misuse EJBs and therefore end up with an application that is difficult to maintain and performs poorly. This paper describes a coding technique to simplify bottom-up EJB development and which enables end-to-end code generation. The examples presented in the paper are based on IBM DB2 Universal Database and WebSphere Studio.

This text was extracted from a PDF file.
At least one non-text object (such as an image or picture) has been suppressed.
This is the abbreviated version, containing approximately 40% of the total text.

Page 1 of 4

Generic Entity EJB SQL wrapper and code generator

Disclosed is a design pattern that generalizes the use of entity EJBs to simplify EJB development. EJBs are designed to help significantly reduce development time for enterprise applications. As a quick review, there are two types of EJBs: session beans that provide business logic, and entity beans that encapsulate business data. Session beans are analogous to database stored procedures, and entity beans are analogous to database result sets. EJBs provide built-in features for remote access, scalability, security, and transactions. These built-in features do not come without cost. A simple stored procedure, one that does a single SQL statement, is one small source file. A simple session EJB that performs the same task requires more than 10 class files. It is easy to misuse EJBs and therefore end up with an application that is difficult to maintain and performs poorly

Java 2 Enterprise Edition (J2EE) uses entity EJBs to provide a layer of abstraction to the underlying relational database system. However, the interfaces of entity EJBs complicates the process of simply using SQL statement for database applications. Especially in bottom-up development projects and in legacy database development, design is database-oriented, which means it makes sense for architects to think in terms of SQL calls rather than EJB factories and objects.

In order to solve the problem, a design pattern is developed to generalize the use of entity EJB. The design pattern retains the intuitive SQL interface, yet delivers the reusability and built-in distributed transaction support of EJBs. Many common cases can be handled. Because it is generalized, it can be used for automatic code generation. Given a database table, the bottom-up approach can generate code from Container-Managed Persistence (CMP) entity beans, session beans, up to a Java Server Page (JSP) or even a Web service.

The generic entity EJB wrapper

The generic SQL entity EJB wrapper is a helper class that manipulates entity EJB factories and remote interfaces to achieve the goal as to execute certain SQL statements by providing an intuitive SQL interface.

Figure 1 illustrates a typical EJB façade pattern. The EJB session façade pattern provides a stable, high-level gateway to the server-side components. The model layer consists of the relational database and a collection of entity EJBs. Each entity bean is an abstraction of a row of data; the relational database is responsible for persistent storage. The business layer consists of a session EJB , which is a client to the entity bean. Any method defined in the session bean is a transaction. The method in the session bean is where you implement the business logic.

1

Page 2 of 4

findByPrimaryKey() findByXXX() create()
remove() getXXX() setXXX()

Database

Entity EJB

Session EJB

Entity EJB

RMI/IIOP

JDBC

Entity EJB

Business Layer

Model Layer

Figure 1. EJB programming model

The functions inside the entity...