Oracle TopLink Developer's Guide
10g Release 3 (10.1.3) B13593-01 |
|
![]() Previous |
![]() Next |
TopLink provides a useCollectionClass
method to all subclasses of DataReadQuery
and ReadAllQuery
, that you can use to configure a query to return results as any concrete instance of Collection
or Map
.
Do not confuse collection query result configuration with a mapping container policy (see "Configuring Container Policy"): there is no relationship between the two. Collection query result configuration determines how TopLink returns multiobject results from a particular query. A mapping container policy tells TopLink how your domain object implements a data member that contains a collection.
For example, consider a class Employee
with a data member phoneNumbers
. In your implementation of Employee
, the getPhoneNumbers
method returns a Vector
. Using TopLink Workbench, you map the phoneNumbers
data member as a one-to-many mapping. You configure the mapping container policy so that the mapping contains its value (many PhoneNumber
objects) in a Vector
. This corresponds to your implementation of Employee
.
You define a ReadAllQuery
named localPhoneNumbers
on the DescriptorQueryManager
of the PhoneNumber
. The localPhoneNumbers
query takes one argument, the ID of an Employee
object, and returns all the phone numbers from its phoneNumbers
data member whose area code is 613.
You get this query by name from the DescriptorQueryManager
for PhoneNumber
. You call the useCollectionClass
method on this ReadAllQuery
, passing in the ArrayList
class. You execute the query, passing in the ID of an Employee
. The query returns all the PhoneNumber
objects from the Employee
object's phoneNumbers
data member whose area code is 613. The query returns these results as an ArrayList
.