Table data gateway pattern

From CSSEMediaWiki
Revision as of 08:41, 17 October 2010 by James Ashford (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Contents

Table Gateway Pattern

An object that acts as a Gateway to a database table. One instance handles all the rows in the table.

How it works

A simple interface that directly maps onto the database. The class contains all the SQL to access the data from the database and simply return a RecordSet (or similar) of the data. The entire system is stateless, and any changes to the underlying database needs to be done with the Gateway class.

When to use it

For very simple database access. Stored procedures themselves are often organized as Table Data Gateways

Example

class PersonGateway {

find(id): RecordSet

findByLastName(String) : RecordSet

update(id, name, address, ...)

insert(name, address,...)

delete(id)

}

Personal tools