User's Manual

100 Chapter 9. Persistence Tutorial
Suppose you are defining an object type named "ChewingGum" that extends ACSObject. To
specify that an object type extends another, do the following:
Before defining your object type but after declaring your model, make sure to import the
ACSObject type.
import com.arsdigita.kernel.*;
When defining your object type, specify that the supertype of the "Chewing Gum" object
type is "ACSObject" and import the namespace for ACSObject. In the PDL file, you cur-
rently write:
object type ChewingGum extends ACSObject {
---
}
When you define your table in the database, make the primary key reference the
acs_objects table. This is only required, however, when you manually specify your
SQL. In most cases, defining the PDL will be enough to get your started (you must,
however, still load the auto-generated table). The following shows how to manually define
the table.
create table acs_objects (
object_id integer primary key
);
create table chewing_gum (
gum_id integer primary key
references acs_objects(object_id)
);
When you create your Java class, you can extend the ACSObject class in the
com.arsdigita.kernel package.
See Section 9.2.6 Object Type Inheritance for a longer example.
2.6. What is a DataQuery and how do I use it?
A DataQuery encapsulates SQL queries. You can retrieve a DataQuery by name from the
PDL file, set filters on its attributes, execute the event, iterate over the result set, and access the
attribute values.
Underneath, the actual SQL query and data model used are hidden from application code.
For more information, see the documentation on Section 9.4 Named SQL Events.
2.7. How do I specify a custom SQL query?
You can create a DataQuery by specifying a SQL query and as many attribute/column map-
pings as you like. You can then define bind variables or set filters on that query to gain the
final query you wish.
2.8. What is an Object/Reference Key and why do I need one?
The object key (Object Key) declared in the PDL files is used by the persistence system
to uniquely identify a particular object in the database. For instance, the object key for
acs_object is "id", which is the name of the attribute that maps to the object_id column
in the acs_objects table.
Object keys can contain singule values or they can be compound (they can be specified using
1 to N attributes). For more information, see Section 9.2.3.3 Object Key.