Name

Procedure Access Object

Goal

Leverage stored procedures in the database by providing a transparent Java interface (Figure B-6).

A PAO object
Figure B-6. A PAO object

Participants

Business tier or presentation tier object

Executes business logic.

PAO

Provides Java code with access to a database stored procedure.

Database stored procedure

Implements business logic within a database system.

Interactions

A business or presentation tier object (the client) creates an instance of a PAO and optionally sets properties. The client calls the PAO’s execute( ) method. The PAO then accesses the database and invokes a stored procedure using the properties passed in by the client. The PAO may perform transformations of the parameters set by the client to match the expectations of the stored procedure. After the stored procedure completes, the client may read additional properties on the PAO to retrieve the results of the stored procedure.

Notes

A PAO can also be implemented using a method-return syntax, in which all input parameters are passed into a single, possibly static, method call on the PAO object. In this case, return values are provided to the client via a DTO object. Also see the GoF Command pattern.

Get J2EE Design Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.