User's Manual

10 Chapter 2. WAF Component: Persistence
For a listing of PDL terms, see Appendix D PDL Syntax. Examples of PDL usage can be found in
Chapter 9 Persistence Tutorial.
2.4. Persistence and Domain APIs (DataObject, DataAssociation,
DataCollection, DomainObjects)
Once an object model is described in PDL, the persistent state associated with it may be directly
accessed and manipulated by Java code through use of the DataObject, DataAssociation, and
DataCollection classes that are part of the WAF persistence API.
Developers can then build upon this API in order to add the behavior required to implement their ap-
plication. This is generally done by extending DomainObject, an abstract base class that encapsulates
a DataObject and uses it to provide persistence capabilities to any derived classes.
2.5. Session and Transaction Management
Domain classes, once written, can be used similarly to any other Java code, with one exception — code
that involves domain objects must be executed within the context of both a session and a transaction.
The session identifies which database that changes are persisted to and queried from, and the trans-
action allows atomic updates of the database. Setup of the current session and transaction is a simple
process that can usually be centrally handled in an application.
Within WAF, session and transaction management is automatically handled by the BaseServlet
class. The transaction model used by WAF persistence is a simple extension of common relational
database transaction semantics:
Transactions cannot be nested.
Once a transaction begins it must either be committed or rolled back.
Transactions must be rolled back after an error occurs.