User's Manual

Chapter 9. Persistence Tutorial 99
2. Developer Specific Questions
2.1. I am new to the persistence API. Where do I start?
Start with this book’s table of contents which lists all available persistence documents. In
addition, the Section 10.2 Domain Objects Tutorial introduces the API used by the WAF and
provides you with code samples for implementing your own Domain Objects.
Additionally, you may want to consult the document on Section 9.2 Beginning With Data
Objects, as well as material on Section 9.5 Filtering, Ordering, and Binding Parameters.
2.2. If I am creating an object type what kind of metadata do I need to define?
The best place to find a full explaination and examples is in the Section 9.2.3 Defining an
Object Type in PDL. However, as a short summary, you must specify the following:
For each attribute:
A mapping of the attribute to the database column in which it resides.
The SQL type of the attribute. For instance, if the data type of the attribute is a string, the
SQL type might be VARCHAR(20) or VARCHAR(4000) or even CLOB.
For each association, it is important to specify the Join Path that the persistence layer will
know how to join the SQL tables to each other.
For each data query, a mapping from the returned attribute name to the data type of the
attribute is required. This allows the code whether an INTEGER SQL type should be an
INTEGER data type or actually a BigDecimal data type.
All of the metadata is required so that the persistence layer can successfully generate a data
model as well as all of the events to manipuate the object.
2.3. Where can I find example PDL (Persistence Definition Language) files that define object
types?
At the top level of any project you will find a pdl directory. In there, you will find many PDL
files that should provide plenty of examples.
2.4. Where do I put my PDL files?
PDL files should be kept in a directory at the same level as the SQL and src files. If the
PDL does not contain any database specific queries (e.g., something containing a connect
by statement) then it should end in (.pdl). Otherwise, you should create a copy of the query
for each database and name each copy appropriately: .ora.pdl for Oracle or .pg.pdl for
PostgreSQL.
2.5. I want to create a new object type that extends ACSObject. What do I do?
When you extend an object type, the new object type will inherit all the properties (attributes
and role references) of the super type. A child object type can override the parent’s attributes
(but not role references), as long as the new attribute does not violate any constraints placed
on the supertype’s attribute. For example, suppose that the parties object type defines an email
attribute that is required. That is, parties.email has multiplicity of 1..1. You can create a persons
object type that extends parties. You cannot make the email address optional in the persons
object type because it is already required by the supertype.