类 QueryPlanCache
- java.lang.Object
-
- org.hibernate.engine.query.spi.QueryPlanCache
-
- 所有已实现的接口:
Serializable
public class QueryPlanCache extends Object implements Serializable
Acts as a cache for compiled query plans, as well as query-parameter metadata.- 作者:
- Steve Ebersole
- 另请参阅:
AvailableSettings.QUERY_PLAN_CACHE_PARAMETER_METADATA_MAX_SIZE,AvailableSettings.QUERY_PLAN_CACHE_MAX_SIZE, 序列化表格
-
-
字段概要
字段 修饰符和类型 字段 说明 static intDEFAULT_PARAMETER_METADATA_MAX_COUNTThe default strong reference count.static intDEFAULT_QUERY_PLAN_MAX_COUNTThe default soft reference count.
-
构造器概要
构造器 构造器 说明 QueryPlanCache(SessionFactoryImplementor factory)Constructs the QueryPlanCache to be used by the given SessionFactory
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 voidcleanup()Clean up the caches when the SessionFactory is closed.FilterQueryPlangetFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map<String,Filter> enabledFilters)Get the query plan for the given collection HQL filter fragment, creating it and caching it if not already cachedHQLQueryPlangetHQLQueryPlan(String queryString, boolean shallow, Map<String,Filter> enabledFilters)Get the query plan for the given HQL query, creating it and caching it if not already cachedNativeQueryInterpretergetNativeQueryInterpreter()NativeSQLQueryPlangetNativeSQLQueryPlan(NativeSQLQuerySpecification spec)Get the query plan for a native SQL query, creating it and caching it if not already cachedParameterMetadatagetSQLParameterMetadata(String query, boolean isOrdinalParameterZeroBased)Obtain the parameter metadata for given native-sql query.
-
-
-
构造器详细资料
-
QueryPlanCache
public QueryPlanCache(SessionFactoryImplementor factory)
Constructs the QueryPlanCache to be used by the given SessionFactory- 参数:
factory- The SessionFactory
-
-
方法详细资料
-
getSQLParameterMetadata
public ParameterMetadata getSQLParameterMetadata(String query, boolean isOrdinalParameterZeroBased)
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- 参数:
query- The query- 返回:
- The parameter metadata
-
getHQLQueryPlan
public HQLQueryPlan getHQLQueryPlan(String queryString, boolean shallow, Map<String,Filter> enabledFilters) throws QueryException, MappingException
Get the query plan for the given HQL query, creating it and caching it if not already cached- 参数:
queryString- The HQL query stringshallow- Whether the execution will be shallowenabledFilters- The filters enabled on the Session- 返回:
- The query plan
- 抛出:
QueryException- Indicates a problem translating the queryMappingException- Indicates a problem translating the query
-
getFilterQueryPlan
public FilterQueryPlan getFilterQueryPlan(String filterString, String collectionRole, boolean shallow, Map<String,Filter> enabledFilters) throws QueryException, MappingException
Get the query plan for the given collection HQL filter fragment, creating it and caching it if not already cached- 参数:
filterString- The HQL filter fragmentcollectionRole- The collection being filteredshallow- Whether the execution will be shallowenabledFilters- The filters enabled on the Session- 返回:
- The query plan
- 抛出:
QueryException- Indicates a problem translating the queryMappingException- Indicates a problem translating the query
-
getNativeSQLQueryPlan
public NativeSQLQueryPlan getNativeSQLQueryPlan(NativeSQLQuerySpecification spec)
Get the query plan for a native SQL query, creating it and caching it if not already cached- 参数:
spec- The native SQL query specification- 返回:
- The query plan
- 抛出:
QueryException- Indicates a problem translating the queryMappingException- Indicates a problem translating the query
-
cleanup
public void cleanup()
Clean up the caches when the SessionFactory is closed.Note that depending on the cache strategy implementation chosen, clearing the cache might not reclaim all the memory.
Typically, when using LIRS, clearing the cache only invalidates the entries but the outdated entries are kept in memory until they are replaced by others. It is not considered a memory leak as the cache is bounded.
-
getNativeQueryInterpreter
public NativeQueryInterpreter getNativeQueryInterpreter()
-
-