Interface Statistics

  • All Known Subinterfaces:
    StatisticsImplementor

    @MXBean
    public interface Statistics
    Exposes statistics for a particular SessionFactory. Beware of milliseconds metrics, they are dependent of the JVM precision: you may then encounter a 10 ms approximation depending on you OS platform. Please refer to the JVM documentation for more information.
    • Field Detail

      • DEFAULT_QUERY_STATISTICS_MAX_SIZE

        static final int DEFAULT_QUERY_STATISTICS_MAX_SIZE
        See Also:
        Constant Field Values
    • Method Detail

      • isStatisticsEnabled

        boolean isStatisticsEnabled()
        Are statistics enabled
      • setStatisticsEnabled

        void setStatisticsEnabled​(boolean b)
        Enable statistics logs (this is a dynamic parameter)
      • clear

        void clear()
        reset all statistics
      • logSummary

        void logSummary()
        log in info level the main statistics
      • getEntityStatistics

        EntityStatistics getEntityStatistics​(String entityName)
        find entity statistics per name
        Parameters:
        entityName - entity name
        Returns:
        EntityStatistics object
      • getCollectionStatistics

        CollectionStatistics getCollectionStatistics​(String role)
        Get collection statistics per role
        Parameters:
        role - collection role
        Returns:
        CollectionStatistics
      • getNaturalIdStatistics

        NaturalIdStatistics getNaturalIdStatistics​(String entityName)
        Natural id resolution query statistics for an entity type
        Parameters:
        entityName - The entity name that is the root of the hierarchy containing the natural id
        Returns:
        NaturalIdCacheStatistics
      • getQueryStatistics

        QueryStatistics getQueryStatistics​(String queryString)
        Query statistics from query string (HQL or SQL)
        Parameters:
        queryString - query string
        Returns:
        QueryStatistics
      • getDomainDataRegionStatistics

        CacheRegionStatistics getDomainDataRegionStatistics​(String regionName)
        Second-level cache statistics per domain data (entity, collection, natural-id) region
        Parameters:
        regionName - The unqualified region name
        Returns:
        The stats for the named region, or null if the second level cache is not enabled
        Throws:
        IllegalArgumentException - if the region name could not be resolved
      • getQueryRegionStatistics

        CacheRegionStatistics getQueryRegionStatistics​(String regionName)
        Second-level cache statistics per query region
        Parameters:
        regionName - The unqualified region name
        Returns:
        Stats for the named region, or null if (1) query result caching is not enabled or (2) no query region exists with that name
      • getCacheRegionStatistics

        CacheRegionStatistics getCacheRegionStatistics​(String regionName)
        Get statistics for either a domain-data or query-result region - this method checks both, preferring domain data region if one. Think of it as a cascading check to:
        1. getDomainDataRegionStatistics(java.lang.String)
        2. getQueryRegionStatistics(java.lang.String)
        Note that returning null is preferred here over throwing an exception when no region exists with that name.
        Parameters:
        regionName - The unqualified region name
        Returns:
        Stats for the named region, or null if no such region exists
      • getEntityDeleteCount

        long getEntityDeleteCount()
        Get global number of entity deletes
        Returns:
        entity deletion count
      • getEntityInsertCount

        long getEntityInsertCount()
        Get global number of entity inserts
        Returns:
        entity insertion count
      • getEntityLoadCount

        long getEntityLoadCount()
        Get global number of entity loads
        Returns:
        entity load (from DB)
      • getEntityFetchCount

        long getEntityFetchCount()
        Get global number of entity fetches
        Returns:
        entity fetch (from DB)
      • getEntityUpdateCount

        long getEntityUpdateCount()
        Get global number of entity updates
        Returns:
        entity update
      • getQueryExecutionCount

        long getQueryExecutionCount()
        Get global number of executed queries
        Returns:
        query execution count
      • getQueryExecutionMaxTime

        long getQueryExecutionMaxTime()
        Get the time in milliseconds of the slowest query.
      • getQueryExecutionMaxTimeQueryString

        String getQueryExecutionMaxTimeQueryString()
        Get the query string for the slowest query.
      • getQueryCacheHitCount

        long getQueryCacheHitCount()
        Get the global number of cached queries successfully retrieved from cache
      • getQueryCacheMissCount

        long getQueryCacheMissCount()
        Get the global number of cached queries *not* found in cache
      • getQueryCachePutCount

        long getQueryCachePutCount()
        Get the global number of cacheable queries put in cache
      • getNaturalIdQueryExecutionCount

        long getNaturalIdQueryExecutionCount()
        Get the global number of natural id queries executed against the database
      • getNaturalIdQueryExecutionMaxTime

        long getNaturalIdQueryExecutionMaxTime()
        Get the global maximum query time for natural id queries executed against the database
      • getNaturalIdQueryExecutionMaxTimeRegion

        String getNaturalIdQueryExecutionMaxTimeRegion()
        Get the region for the maximum natural id query time
      • getNaturalIdQueryExecutionMaxTimeEntity

        String getNaturalIdQueryExecutionMaxTimeEntity()
        Get the entity for the maximum natural id query time
      • getNaturalIdCacheHitCount

        long getNaturalIdCacheHitCount()
        Get the global number of cached natural id lookups successfully retrieved from cache
      • getNaturalIdCacheMissCount

        long getNaturalIdCacheMissCount()
        Get the global number of cached natural id lookups *not* found in cache
      • getNaturalIdCachePutCount

        long getNaturalIdCachePutCount()
        Get the global number of cacheable natural id lookups put in cache
      • getUpdateTimestampsCacheHitCount

        long getUpdateTimestampsCacheHitCount()
        Get the global number of timestamps successfully retrieved from cache
      • getUpdateTimestampsCacheMissCount

        long getUpdateTimestampsCacheMissCount()
        Get the global number of timestamp requests that were not found in the cache
      • getUpdateTimestampsCachePutCount

        long getUpdateTimestampsCachePutCount()
        Get the global number of timestamps put in cache
      • getFlushCount

        long getFlushCount()
        Get the global number of flush operations executed (either manual or automatic).
      • getConnectCount

        long getConnectCount()
        Get the global number of connections asked by the sessions (the actual number of connections used may be much smaller depending whether you use a connection pool or not)
      • getSecondLevelCacheHitCount

        long getSecondLevelCacheHitCount()
        Global number of cacheable entities/collections successfully retrieved from the cache
      • getSecondLevelCacheMissCount

        long getSecondLevelCacheMissCount()
        Global number of cacheable entities/collections not found in the cache and loaded from the database.
      • getSecondLevelCachePutCount

        long getSecondLevelCachePutCount()
        Global number of cacheable entities/collections put in the cache
      • getSessionCloseCount

        long getSessionCloseCount()
        Global number of sessions closed
      • getSessionOpenCount

        long getSessionOpenCount()
        Global number of sessions opened
      • getCollectionLoadCount

        long getCollectionLoadCount()
        Global number of collections loaded
      • getCollectionFetchCount

        long getCollectionFetchCount()
        Global number of collections fetched
      • getCollectionUpdateCount

        long getCollectionUpdateCount()
        Global number of collections updated
      • getCollectionRemoveCount

        long getCollectionRemoveCount()
        Global number of collections removed
      • getCollectionRecreateCount

        long getCollectionRecreateCount()
        Global number of collections recreated
      • getStartTime

        long getStartTime()
        The milliseconds (JVM standard System.currentTimeMillis()) since the initial creation of this Statistics instance or the last time clear() was called.
        ApiNote:
        This time(stamp) is
      • getQueries

        String[] getQueries()
        Get all executed query strings. The maximum number of queries tracked by the Hibernate statistics is given by the hibernate.statistics.query_max_size property.
      • getEntityNames

        String[] getEntityNames()
        Get the names of all entities
      • getCollectionRoleNames

        String[] getCollectionRoleNames()
        Get the names of all collection roles
      • getSecondLevelCacheRegionNames

        String[] getSecondLevelCacheRegionNames()
        Get all second-level cache region names. Note: for backwards compatibility this method returns just the names of regions storing domain data, not query result regions
      • getSuccessfulTransactionCount

        long getSuccessfulTransactionCount()
        The number of transactions we know to have been successful
      • getTransactionCount

        long getTransactionCount()
        The number of transactions we know to have completed
      • getPrepareStatementCount

        long getPrepareStatementCount()
        The number of prepared statements that were acquired
      • getCloseStatementCount

        long getCloseStatementCount()
        The number of prepared statements that were released
      • getOptimisticFailureCount

        long getOptimisticFailureCount()
        The number of Hibernate StaleObjectStateExceptions or JPA OptimisticLockExceptions that occurred.
      • getQueryPlanCacheHitCount

        default long getQueryPlanCacheHitCount()
        Get the global number of query plans successfully retrieved from cache
      • getQueryPlanCacheMissCount

        default long getQueryPlanCacheMissCount()
        Get the global number of query plans lookups *not* found in cache