Skip Headers

# Partial Object Queries

Previous

Next

By default, an `ObjectLevelReadQuery` returns all attributes of the objects read.

If you require only certain attributes from selected objects, you can create a partial object query by using `ObjectLevelReadQuery` method `addPartialAttributes`. Using this method, you can improve query performance by making TopLink return objects with only specified attributes populated.

Applications frequently use partial object queries to compile a list for further selection. For example, a query to find the names and addresses of all employees over the age of 40 returns a list of data (the names and addresses) that partially represents objects (the employees). A common next step is to present this list so the user can select the required object or objects from the list. Later retrieval of a complete object is simplified because TopLink always includes the primary key attribute (even if you do not add it as a partial attribute.

Consider the following when you use partial object queries:

- You cannot edit or cache partial objects.

- Unspecified attributes will be left `null`.

- You cannot have two partial attributes of the same type.

- You cannot add a partial attribute which is of the same type as the class being queried.

If you require only summary information for certain attributes from selected objects, it is more efficient to use a `ReportQuery` (see "Report Query").

For more information, see "Reading Objects Using Partial Object Queries".