Class QueryPlanCache

    • Field Detail

      • DEFAULT_PARAMETER_METADATA_MAX_COUNT

        public static final int DEFAULT_PARAMETER_METADATA_MAX_COUNT
        The default strong reference count.
        See Also:
        Constant Field Values
      • DEFAULT_QUERY_PLAN_MAX_COUNT

        public static final int DEFAULT_QUERY_PLAN_MAX_COUNT
        The default soft reference count.
        See Also:
        Constant Field Values
    • Method Detail

      • getSQLParameterMetadata

        public ParameterMetadata getSQLParameterMetadata​(java.lang.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

        Parameters:
        query - The query
        Returns:
        The parameter metadata
      • getHQLQueryPlan

        public HQLQueryPlan getHQLQueryPlan​(java.lang.String queryString,
                                            boolean shallow,
                                            java.util.Map<java.lang.String,​Filter> enabledFilters)
                                     throws QueryException,
                                            MappingException
        Get the query plan for the given HQL query, creating it and caching it if not already cached
        Parameters:
        queryString - The HQL query string
        shallow - Whether the execution will be shallow
        enabledFilters - The filters enabled on the Session
        Returns:
        The query plan
        Throws:
        QueryException - Indicates a problem translating the query
        MappingException - Indicates a problem translating the query
      • getFilterQueryPlan

        public FilterQueryPlan getFilterQueryPlan​(java.lang.String filterString,
                                                  java.lang.String collectionRole,
                                                  boolean shallow,
                                                  java.util.Map<java.lang.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
        Parameters:
        filterString - The HQL filter fragment
        collectionRole - The collection being filtered
        shallow - Whether the execution will be shallow
        enabledFilters - The filters enabled on the Session
        Returns:
        The query plan
        Throws:
        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
        Parameters:
        spec - The native SQL query specification
        Returns:
        The query plan
        Throws:
        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.