User's Manual

88 Chapter 9. Persistence Tutorial
9.5.4. How it Works
You may be wondering how to add filters and bind variables after retrieving the query. The persistence
system does not actually execute the required SQL query until the first call to next(). Therefore, the
DataQuery (or DataCollection or DataAssociationCursor) can be passed around and have
Filters and ORDER BY statements added and variables bound before the first element is retrieved.
Then, when the first element is retrieved, the query is executed and the code can no longer add or
remove filters or ordering criteria.
9.6. Common Mistakes
9.6.1. Introduction
As developers use the persistence layer of the WAF, several types of errors are made by many devel-
opers. This document tries to highlight some of those errors to help with debugging tasks. Another
document that may be of interest to developers having problems with persistence is the Section 9.10
Frequently Asked Questions.
9.6.2. Use of Semi-Colons; Invalid Character Error
One of the most common and most easily fixed errors is that of an invalid character. The error is
typically something such as:
com.arsdigita.persistence.PersistenceException: ORA-00911: invalid character
This error is caused because the developer accidentally included a semi-colon at the end of a SQL
statement. For instance, the following retrieve event will cause the above error because of the
semi-colon (in bold) at the end:
retrieve {
do {
select publication_id, name
from publications
where publication_id = :id;
} map {
id = publications.publication_id;
name = publications.name;
}
}
To fix the error, simply remove the semi-colon so that the event definition appears as follows:
retrieve {
do {
select publication_id, name
from publications
where publication_id = :id
} map {
id = publications.publication_id;
name = publications.name;
}
}
This error occurs is because the query is fed directly to the database using the JDBC driver, which
does not exptect a trailing semi-colon.