类 QueryPlanCache

    • 字段详细资料

      • DEFAULT_PARAMETER_METADATA_MAX_COUNT

        public static final int DEFAULT_PARAMETER_METADATA_MAX_COUNT
        The default strong reference count.
        另请参阅:
        常量字段值
      • DEFAULT_QUERY_PLAN_MAX_COUNT

        public static final int DEFAULT_QUERY_PLAN_MAX_COUNT
        The default soft reference count.
        另请参阅:
        常量字段值
    • 构造器详细资料

      • 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 string
        shallow - Whether the execution will be shallow
        enabledFilters - The filters enabled on the Session
        返回:
        The query plan
        抛出:
        QueryException - Indicates a problem translating the query
        MappingException - 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 fragment
        collectionRole - The collection being filtered
        shallow - Whether the execution will be shallow
        enabledFilters - The filters enabled on the Session
        返回:
        The query plan
        抛出:
        QueryException - Indicates a problem translating the query
        MappingException - 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 query
        MappingException - 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.