Top Description Inners Fields Constructors Methods
org.hibernate.engine.query

public Class QueryPlanCache

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Imports
org.hibernate.util.PropertiesHelper, .SimpleMRUCache, .SoftLimitMRUCache, .CollectionHelper, org.hibernate.cfg.Environment, org.hibernate.engine.SessionFactoryImplementor, org.hibernate.engine.query.sql.NativeSQLQuerySpecification, org.hibernate.QueryException, .MappingException, org.hibernate.impl.FilterImpl, org.slf4j.Logger, .LoggerFactory, java.io.Serializable, java.util.Map, .HashMap, .Iterator, .Set, .HashSet, .Collections, .Collection

Acts as a cache for compiled query plans, as well as query-parameter metadata.
Author
Steve Ebersole
See Also
Environment#QUERY_PLAN_CACHE_MAX_STRONG_REFERENCES, Environment#QUERY_PLAN_CACHE_MAX_SOFT_REFERENCES

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class

Field Summary

Modifier and TypeField and Description
private SessionFactoryImplementor
private static final Logger
private final SoftLimitMRUCache
planCache

the cache of the actual plans...

private final SimpleMRUCache
sqlParamMetadataCache

simple cache of param metadata based on query string.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private ParameterMetadata
public FilterQueryPlan
getFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map<K, V> enabledFilters)

public HQLQueryPlan
getHQLQueryPlan(String queryString, boolean shallow, Map<K, V> enabledFilters)

public NativeSQLQueryPlan
public ParameterMetadata

Returns:

The parameter metadata
getSQLParameterMetadata
(String
The query
query
)

Obtain the parameter metadata for given native-sql query.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

factoryback to summary
private SessionFactoryImplementor factory
logback to summary
private static final Logger log
planCacheback to summary
private final SoftLimitMRUCache planCache

the cache of the actual plans...

sqlParamMetadataCacheback to summary
private final SimpleMRUCache sqlParamMetadataCache

simple cache of param metadata based on query string. Ideally, the original "user-supplied query" string should be used to obtain this metadata (i.e., not the para-list-expanded query string) to avoid unnecessary cache entries.

Used solely for caching param metadata for native-sql queries, see getSQLParameterMetadata for a discussion as to why...

Constructor Detail

QueryPlanCacheback to summary
public QueryPlanCache(SessionFactoryImplementor factory)

Method Detail

buildNativeSQLParameterMetadataback to summary
private ParameterMetadata buildNativeSQLParameterMetadata(String sqlString)
Annotations
@SuppressWarnings:UnnecessaryUnboxing
getFilterQueryPlanback to summary
public FilterQueryPlan getFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map<K, V> enabledFilters) throws QueryException, MappingException
getHQLQueryPlanback to summary
public HQLQueryPlan getHQLQueryPlan(String queryString, boolean shallow, Map<K, V> enabledFilters) throws QueryException, MappingException
getNativeSQLQueryPlanback to summary
public NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec)
getSQLParameterMetadataback to summary
public ParameterMetadata getSQLParameterMetadata(String query)

Obtain the parameter metadata for given native-sql query.

for native-sql queries, the param metadata is determined outside any relation to a query plan, because query plan creation and/or retrieval for a native-sql query depends on all of the return types having been set, which might not be the case up-front when param metadata would be most useful

Parameters
query:String

The query

Returns:ParameterMetadata

The parameter metadata

org.hibernate.engine.query back to summary

private Class QueryPlanCache.DynamicFilterKey

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private final int
private final Map<String, Integer>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

filterNameback to summary
private final String filterName
hashCodeback to summary
private final int hashCode
parameterMetadataback to summary
private final Map<String, Integer> parameterMetadata

Constructor Detail

DynamicFilterKeyback to summary
private DynamicFilterKey(FilterImpl filter)
Annotations
@SuppressWarnings:UnnecessaryBoxing

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

org.hibernate.engine.query back to summary

private Class QueryPlanCache.FilterQueryPlanKey

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final String
private final Set<String>
private final int
private final String
private final boolean

Constructor Summary

AccessConstructor and Description
public
FilterQueryPlanKey(String query, String collectionRole, boolean shallow, Map<K, V> enabledFilters)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionRoleback to summary
private final String collectionRole
filterNamesback to summary
private final Set<String> filterNames
hashCodeback to summary
private final int hashCode
queryback to summary
private final String query
shallowback to summary
private final boolean shallow

Constructor Detail

FilterQueryPlanKeyback to summary
public FilterQueryPlanKey(String query, String collectionRole, boolean shallow, Map<K, V> enabledFilters)
Annotations
@SuppressWarnings:unchecked

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

org.hibernate.engine.query back to summary

private Class QueryPlanCache.HQLQueryPlanKey

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
private final Set<QueryPlanCache.DynamicFilterKey>
private final int
private final String
private final boolean

Constructor Summary

AccessConstructor and Description
public
HQLQueryPlanKey(String query, boolean shallow, Map<K, V> enabledFilters)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

filterKeysback to summary
private final Set<QueryPlanCache.DynamicFilterKey> filterKeys
hashCodeback to summary
private final int hashCode
queryback to summary
private final String query
shallowback to summary
private final boolean shallow

Constructor Detail

HQLQueryPlanKeyback to summary
public HQLQueryPlanKey(String query, boolean shallow, Map<K, V> enabledFilters)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.