|
Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
You can set the query manager to automatically append an expression to every query it performs on a class. For example, you can add an expression that filters the database for the valid instances of a given class.
Use this to do the following:
Filter logically deleted objects
Enable two independent classes to share a single table without inheritance
Filter historical versions of objects
Using Java, configure a descriptor with additional join expressions by creating an amendment method (see "Configuring Amendment Methods"), and then using the DescriptorQueryManager methods setAdditionalJoinExpression or setMultipleTableJoinExpression, as Example 99-6 shows.
Example 99-6 Registering a Query That Includes a Join Expression
In Example 99-6, the join expression filters invalid instances of employee from the query.
public static void addToDescriptor(Descriptor descriptor)
{
ExpressionBuilder builder = new ExpressionBuilder();
descriptor.getQueryManager().setAdditionalJoinExpression(
(builder.getField("EMP.STATUS").notEqual("DELETED")).and(
builder.getField("EMP.STATUS").notEqual("HISTORICAL"))
);
}