Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
A query key is a schema-independent alias for a database field name.
Query keys are supported in relational database projects only.
Query keys are generated automatically for all direct and relationship mappings. The name of the query key is the class attribute name.
For more information on how query keys are created and modified, see "Configuring Query Keys".
Example 97-15 illustrates how to use the query key firstName
for the corresponding directly mapped Employee
attribute.
Example 97-15 Using an Automatically Generated Query Key in an Expression
Vector employees = session.readAllObjects(Employee.class, new ExpressionBuilder().get("firstName").equal("Bob"));
Example 97-16 illustrates how to use a one-to-one query key within the TopLink expression framework.
Example 97-16 Using a One-to-One Query Key in an Expression
ExpressionBuilder employee = new ExpressionBuilder(); Vector employees = session.readAllObjects(Employee.class, employee.get("address").get("city").equal("Ottawa"));
To access one-to-many and many-to-many query keys that define a distinct join across a collection relationship, use Expression
method anyOf
.
WARNING: Allowing an unverified SQL string to be passed into methods (for example: |