Skip Headers

Oracle TopLink Developer's Guide 10g Release 3 (10.1.3) B13593-01 |
| Home | Solution Area | Contents | Index

Previous | Next |

# Using Queries on Variable One-to-One Mappings

TopLink does not provide a method to directly query against variable one-to-one mappings. To query against this type of mapping, combine TopLink `DirectQueryKeys` and TopLink `ReportQueries` to create query selection criteria for classes that implement the interface, as follows:

1. Create two `DirectQueryKeys` to query for the possible implementors of the interface:

   - The first `DirectQueryKey` is for the class indicator field for the variable one-to-one mapping.

   - The second `DirectQueryKey` is for the foreign key to the class or table that implements the interface.

2. Create a `subSelect` statement for each concrete class that implements the interface included in the query selection criteria.

3. Implement a `ReportQuery`.

Example 99-7 Creating DirectQueryKeys

    /* The DirectQueryKeys as generated in the TopLink project Java source code from TopLink Workbench */
    …
    descriptor.addDirectQueryKey("locationTypeCode","DEALLOCATION.DEALLOCATIONOBJECTTYPE");
    descriptor.addDirectQueryKey("locationTypeId","DEALLOCATION.DEALLOCATIONOBJECTID");