QueryHintsHandlerpublic class QueryHintsHandler extends Object The class processes query hints.
TopLink query hints and their values defined in oracle.toplink.essentials.config package.
To add a new query hint:
Define a new hint in TopLinkQueryHints;
Add a class containing hint's values if required to config package (like CacheUsage);
Alternatively values defined in HintValues may be used - Refresh and BindParameters hints do that.
Add an inner class to this class extending Hint corresponding to the new hint (like CacheUsageHint);
The first constructor parameter is hint name; the second is default value;
In constructor
provide 2-dimensional value array in case the values should be translated (currently all Hint classes do that);
in case translation is not required provide a single-dimension array (no such examples yet).
In inner class Hint static initializer addHint an instance of the new hint class (like addHint(new CacheUsageHint())). |
Methods Summary |
---|
public static void | apply(java.util.Map hints, oracle.toplink.essentials.queryframework.DatabaseQuery query)INTERNAL:
Applies the hints to the query.
Throws IllegalArgumentException in case the hint value is illegal.
if(hints == null) {
return;
}
Iterator it = hints.entrySet().iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String hintName = (String)entry.getKey();
apply(hintName, entry.getValue(), query);
}
| public static void | apply(java.lang.String hintName, java.lang.Object hintValue, oracle.toplink.essentials.queryframework.DatabaseQuery query)INTERNAL:
Applies the hint to the query.
Throws IllegalArgumentException in case the hint value is illegal.
Hint.apply(hintName, shouldUseDefault(hintValue), hintValue, query);
| protected static boolean | shouldUseDefault(java.lang.Object hintValue)INTERNAL:
Empty String hintValue indicates that the default hint value
should be used.
return (hintValue != null) && (hintValue instanceof String) && (((String)hintValue).length() == 0);
| public static void | verify(java.util.Map hints, java.lang.String queryName, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Verifies the hints.
If session != null then logs a FINEST message for each hint.
queryName parameter used only for identifying the query in messages,
if it's null then "null" will be used.
Throws IllegalArgumentException in case the hint value is illegal.
if(hints == null) {
return;
}
Iterator it = hints.entrySet().iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String hintName = (String)entry.getKey();
verify(hintName, entry.getValue(), queryName, session);
}
| public static void | verify(java.lang.String hintName, java.lang.Object hintValue, java.lang.String queryName, oracle.toplink.essentials.internal.sessions.AbstractSession session)INTERNAL:
Verifies the hint.
If session != null then logs a FINEST message.
queryName parameter used only for identifying the query in messages,
if it's null then "null" will be used.
Throws IllegalArgumentException in case the hint value is illegal.
Hint.verify(hintName, shouldUseDefault(hintValue), hintValue, queryName, session);
|
|