query-type

Use eclipselink.query-type to specify which Oracle TopLink query type to use for the query.

Values

Table 4-34 describes this query hint's valid values.

Table 4-34 Valid Values for org.eclipse.persistence.config.QueryType

Value Description

Auto

(Default = 0) Oracle TopLink chooses the type of query.

ReadAll

Use a ReadAllQuery.

ReadObject

Use a ReadObjectQuery.

Report

Use a ReportQuery.


Usage

By default, Oracle TopLink uses org.eclipse.persistence.queries.ReportQuery or org.eclipse.persistence.queries.ReadAllQuery for most JPQL queries. Use the eclipselink.query-type hint lets to specify another query type, such as org.eclipse.persistence.queries.ReadObjectQuery for queries that will return a single object.

Examples

Example 4-69 shows how to use this hint in a JPA query.

Example 4-69 Using query-type in a JPA Query

import org.eclipse.persistence.config.QueryType;
 import org.eclipse.persistence.config.QueryHints;
 query.setHint(QueryHints.QUERY_TYPE, QueryType.ReadObject);

Example 4-70 shows how to use this hint with the @QueryHint annotation.

Example 4-70 Using query-type in a @QueryHint Annotation

import org.eclipse.persistence.config.QueryType;
 import org.eclipse.persistence.config.TargetDatabase;
 @QueryHint(name=QueryHints.QUERY_TYPE, value=QueryType.ReadObject);

See Also

For more information, see:

  • "Queries" in Understanding Oracle TopLink