Package org.apache.openjpa.persistence
Class HintHandler
- java.lang.Object
-
- org.apache.openjpa.persistence.HintHandler
-
public class HintHandler extends java.lang.Object
Manages query hint keys and handles their values on behalf of a owningQueryImpl
. Uses specific knowledge of hint keys declared in different parts of the system. This receiver collects hint keys from different parts of the system. The keys are implicitly or explicitly declared by several different mechanics. This receiver sets the values on behalf of a owningQueryImpl
based on the its specific knowledge of these keys. The hint keys from following sources are collected and handled: 1.QueryHints
interface declares hint keys as public static final fields. These fields are collected by reflection. The values are handled by invoking methods on the owningQueryImpl
2. Some hint keys are collected from bean-style property names ofJDBCFetchPlan
byreflection
and prefixed withopenjpa.FetchPlan
. Their values are used to set the corresponding property ofFetchPlan
viareflection
3. Currently definedjakarta.persistence.*
hint keys have a equivalent counterpart to one of these FetchPlan keys. The JPA keys are mapped to equivalent FetchPlan hint keys. 4. Some keys directly invoke setters or add listeners to the owningQueryImpl
. These hint keys are statically declared in this receiver itself. 5. ProductDerivation may introduce their own query hint keys viaProductDerivation.getSupportedQueryHints()
. Their values are set in theFetchConfiguration.setHint(String, Object)
A hint key is classified into one of the following three categories: 1. Supported: A key is known to this receiver as collected from different parts of the system. The value of a supported key is recorded and available viagetHints()
method. 2. Recognized: A key is not known to this receiver but has a prefix which is known to this receiver. The value of a recognized key is not recorded but its value is available viaFetchConfiguration.getHint(String)
3. Unrecognized: A key is neither supported nor recognized. The value of a unrecognized key is neither recorded nor set anywhere. If an incompatible value is supplied for a supported key, a non-fatalArgumentException
is raised.- Since:
- 2.0.0
- Author:
- Pinaki Poddar
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.util.Set<java.lang.String>
_supportedHints
protected QueryImpl<?>
owner
protected static java.lang.String
PREFIX_FETCHPLAN
protected static java.lang.String
PREFIX_JDBC
protected static java.lang.String
PREFIX_OPENJPA
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>
getHints()
Gets all the recorded hint keys and their values.java.util.Set<java.lang.String>
getSupportedHints()
Gets all the supported hint keys.protected boolean
isKnownPrefix(java.lang.String key)
Affirms if the given key starts with any of the known prefix.protected java.lang.Boolean
record(java.lang.String hint, java.lang.Object value)
Record a key-value pair only only if the given key is supported.void
setHint(java.lang.String key, java.lang.Object value)
-
-
-
Field Detail
-
owner
protected final QueryImpl<?> owner
-
_supportedHints
protected static java.util.Set<java.lang.String> _supportedHints
-
PREFIX_OPENJPA
protected static final java.lang.String PREFIX_OPENJPA
- See Also:
- Constant Field Values
-
PREFIX_JDBC
protected static final java.lang.String PREFIX_JDBC
- See Also:
- Constant Field Values
-
PREFIX_FETCHPLAN
protected static final java.lang.String PREFIX_FETCHPLAN
- See Also:
- Constant Field Values
-
-
Method Detail
-
record
protected java.lang.Boolean record(java.lang.String hint, java.lang.Object value)
Record a key-value pair only only if the given key is supported.- Returns:
- FALSE if the key is unrecognized. null (i.e. MAY BE) if the key is recognized, but not supported. TRUE if the key is supported.
-
setHint
public void setHint(java.lang.String key, java.lang.Object value)
-
isKnownPrefix
protected boolean isKnownPrefix(java.lang.String key)
Affirms if the given key starts with any of the known prefix.- Parameters:
key
-
-
getSupportedHints
public java.util.Set<java.lang.String> getSupportedHints()
Gets all the supported hint keys. The set of supported hint keys is statically determined by collecting hint keys from the ProductDerivations.
-
getHints
public java.util.Map<java.lang.String,java.lang.Object> getHints()
Gets all the recorded hint keys and their values.
-
-