Use eclipselink.query-type
to specify which EclipseLink 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 |
---|---|
|
(Default = |
|
Use a |
|
Use a |
|
Use a |
Usage
By default, EclipseLink 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 EclipseLink