Top Description Fields Methods
org.hibernate.stat

public Interface Statistics

Known Direct Subinterfaces
org.hibernate.stat.spi.StatisticsImplementor
Annotations
@MXBean
Imports
javax.management.MXBean

Exposes statistics for a particular org.hibernate.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.
Author
Emmanuel Bernard

Field Summary

Modifier and TypeField and Description
public static final int

Method Summary

Modifier and TypeMethod and Description
public void
clear()

reset all statistics

public CacheRegionStatistics

Returns:

Stats for the named region, or null if no such region exists
getCacheRegionStatistics
(String
The unqualified region name
regionName
)

Get statistics for either a domain-data or query-result region - this method checks both, preferring domain data region if one.

public long
getCloseStatementCount()

The number of prepared statements that were released

public long
getCollectionFetchCount()

Global number of collections fetched

public long
getCollectionLoadCount()

Global number of collections loaded

public long
getCollectionRecreateCount()

Global number of collections recreated

public long
getCollectionRemoveCount()

Global number of collections removed

public String[]
getCollectionRoleNames()

Get the names of all collection roles

public CollectionStatistics

Returns:

CollectionStatistics
getCollectionStatistics
(String
collection role
role
)

Get collection statistics per role

public long
getCollectionUpdateCount()

Global number of collections updated

public 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)

public CacheRegionStatistics

Returns:

The stats for the named region, or null if the second level cache is not enabled
getDomainDataRegionStatistics
(String
The unqualified region name
regionName
)

Second-level cache statistics per domain data (entity, collection, natural-id) region

public long

Returns:

entity deletion count
getEntityDeleteCount
()

Get global number of entity deletes

public long

Returns:

entity fetch (from DB)
getEntityFetchCount
()

Get global number of entity fetches

public long

Returns:

entity insertion count
getEntityInsertCount
()

Get global number of entity inserts

public long

Returns:

entity load (from DB)
getEntityLoadCount
()

Get global number of entity loads

public String[]
getEntityNames()

Get the names of all entities

public EntityStatistics

Returns:

EntityStatistics object
getEntityStatistics
(String
entity name
entityName
)

find entity statistics per name

public long

Returns:

entity update
getEntityUpdateCount
()

Get global number of entity updates

public long
getFlushCount()

Get the global number of flush operations executed (either manual or automatic).

public long
getNaturalIdCacheHitCount()

Get the global number of cached natural id lookups successfully retrieved from cache

public long
getNaturalIdCacheMissCount()

Get the global number of cached natural id lookups *not* found in cache

public long
getNaturalIdCachePutCount()

Get the global number of cacheable natural id lookups put in cache

public NaturalIdCacheStatistics

Returns:

NaturalIdCacheStatistics
getNaturalIdCacheStatistics
(String
region name
regionName
)

Deprecated (since 5.3) Use getNaturalIdStatistics or getDomainDataRegionStatistics instead depending on need
Natural id cache statistics per region
public long
getNaturalIdQueryExecutionCount()

Get the global number of natural id queries executed against the database

public long
getNaturalIdQueryExecutionMaxTime()

Get the global maximum query time for natural id queries executed against the database

public String
getNaturalIdQueryExecutionMaxTimeEntity()

Get the entity for the maximum natural id query time

public String
getNaturalIdQueryExecutionMaxTimeRegion()

Get the region for the maximum natural id query time

public NaturalIdStatistics

Returns:

NaturalIdCacheStatistics
getNaturalIdStatistics
(String
The entity name that is the root of the hierarchy containing the natural id
entityName
)

Natural id resolution query statistics for an entity type

public long
getOptimisticFailureCount()

The number of Hibernate StaleObjectStateExceptions or JPA OptimisticLockExceptions that occurred.

public long
getPrepareStatementCount()

The number of prepared statements that were acquired

public String[]
getQueries()

Get all executed query strings.

public long
getQueryCacheHitCount()

Get the global number of cached queries successfully retrieved from cache

public long
getQueryCacheMissCount()

Get the global number of cached queries *not* found in cache

public long
getQueryCachePutCount()

Get the global number of cacheable queries put in cache

public long

Returns:

query execution count
getQueryExecutionCount
()

Get global number of executed queries

public long
getQueryExecutionMaxTime()

Get the time in milliseconds of the slowest query.

public String
getQueryExecutionMaxTimeQueryString()

Get the query string for the slowest query.

public default long
getQueryPlanCacheHitCount()

Get the global number of query plans successfully retrieved from cache

public default long
getQueryPlanCacheMissCount()

Get the global number of query plans lookups *not* found in cache

public CacheRegionStatistics

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
getQueryRegionStatistics
(String
The unqualified region name
regionName
)

Second-level cache statistics per query region

public QueryStatistics

Returns:

QueryStatistics
getQueryStatistics
(String
query string
queryString
)

Query statistics from query string (HQL or SQL)

public long
getSecondLevelCacheHitCount()

Global number of cacheable entities/collections successfully retrieved from the cache

public long
getSecondLevelCacheMissCount()

Global number of cacheable entities/collections not found in the cache and loaded from the database.

public long
getSecondLevelCachePutCount()

Global number of cacheable entities/collections put in the cache

public String[]
getSecondLevelCacheRegionNames()

Get all second-level cache region names.

public SecondLevelCacheStatistics

Returns:

SecondLevelCacheStatistics or null if the second level cache is not enabled
getSecondLevelCacheStatistics
(String
qualified region name
regionName
)

Deprecated (since 5.3) Use getDomainDataRegionStatistics instead
Second-level cache statistics per region
public long
getSessionCloseCount()

Global number of sessions closed

public long
getSessionOpenCount()

Global number of sessions opened

public long
getStartTime()

The milliseconds (JVM standard System#currentTimeMillis()) since the initial creation of this Statistics instance or the last time clear() was called.

public long
getSuccessfulTransactionCount()

The number of transactions we know to have been successful

public long
getTransactionCount()

The number of transactions we know to have completed

public long
getUpdateTimestampsCacheHitCount()

Get the global number of timestamps successfully retrieved from cache

public long
getUpdateTimestampsCacheMissCount()

Get the global number of timestamp requests that were not found in the cache

public long
getUpdateTimestampsCachePutCount()

Get the global number of timestamps put in cache

public boolean
isStatisticsEnabled()

Are statistics enabled

public void
logSummary()

log in info level the main statistics

public void
setStatisticsEnabled(boolean b)

Enable statistics logs (this is a dynamic parameter)

Field Detail

DEFAULT_QUERY_STATISTICS_MAX_SIZEback to summary
public static final int DEFAULT_QUERY_STATISTICS_MAX_SIZE

Method Detail

clearback to summary
public void clear()

reset all statistics

getCacheRegionStatisticsback to summary
public 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
  2. getQueryRegionStatistics
Note that returning null is preferred here over throwing an exception when no region exists with that name.
Parameters
regionName:String

The unqualified region name

Returns:CacheRegionStatistics

Stats for the named region, or null if no such region exists

getCloseStatementCountback to summary
public long getCloseStatementCount()

The number of prepared statements that were released

getCollectionFetchCountback to summary
public long getCollectionFetchCount()

Global number of collections fetched

getCollectionLoadCountback to summary
public long getCollectionLoadCount()

Global number of collections loaded

getCollectionRecreateCountback to summary
public long getCollectionRecreateCount()

Global number of collections recreated

getCollectionRemoveCountback to summary
public long getCollectionRemoveCount()

Global number of collections removed

getCollectionRoleNamesback to summary
public String[] getCollectionRoleNames()

Get the names of all collection roles

getCollectionStatisticsback to summary
public CollectionStatistics getCollectionStatistics(String role)

Get collection statistics per role

Parameters
role:String

collection role

Returns:CollectionStatistics

CollectionStatistics

getCollectionUpdateCountback to summary
public long getCollectionUpdateCount()

Global number of collections updated

getConnectCountback to summary
public 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)

getDomainDataRegionStatisticsback to summary
public CacheRegionStatistics getDomainDataRegionStatistics(String regionName)

Second-level cache statistics per domain data (entity, collection, natural-id) region

Parameters
regionName:String

The unqualified region name

Returns:CacheRegionStatistics

The stats for the named region, or null if the second level cache is not enabled

Exceptions
IllegalArgumentException:
if the region name could not be resolved
getEntityDeleteCountback to summary
public long getEntityDeleteCount()

Get global number of entity deletes

Returns:long

entity deletion count

getEntityFetchCountback to summary
public long getEntityFetchCount()

Get global number of entity fetches

Returns:long

entity fetch (from DB)

getEntityInsertCountback to summary
public long getEntityInsertCount()

Get global number of entity inserts

Returns:long

entity insertion count

getEntityLoadCountback to summary
public long getEntityLoadCount()

Get global number of entity loads

Returns:long

entity load (from DB)

getEntityNamesback to summary
public String[] getEntityNames()

Get the names of all entities

getEntityStatisticsback to summary
public EntityStatistics getEntityStatistics(String entityName)

find entity statistics per name

Parameters
entityName:String

entity name

Returns:EntityStatistics

EntityStatistics object

getEntityUpdateCountback to summary
public long getEntityUpdateCount()

Get global number of entity updates

Returns:long

entity update

getFlushCountback to summary
public long getFlushCount()

Get the global number of flush operations executed (either manual or automatic).

getNaturalIdCacheHitCountback to summary
public long getNaturalIdCacheHitCount()

Get the global number of cached natural id lookups successfully retrieved from cache

getNaturalIdCacheMissCountback to summary
public long getNaturalIdCacheMissCount()

Get the global number of cached natural id lookups *not* found in cache

getNaturalIdCachePutCountback to summary
public long getNaturalIdCachePutCount()

Get the global number of cacheable natural id lookups put in cache

getNaturalIdCacheStatisticsback to summary
public NaturalIdCacheStatistics getNaturalIdCacheStatistics(String regionName)

Deprecated

(since 5.3) Use getNaturalIdStatistics or getDomainDataRegionStatistics instead depending on need

Natural id cache statistics per region

Parameters
regionName:String

region name

Returns:NaturalIdCacheStatistics

NaturalIdCacheStatistics

Annotations
@Deprecated
getNaturalIdQueryExecutionCountback to summary
public long getNaturalIdQueryExecutionCount()

Get the global number of natural id queries executed against the database

getNaturalIdQueryExecutionMaxTimeback to summary
public long getNaturalIdQueryExecutionMaxTime()

Get the global maximum query time for natural id queries executed against the database

getNaturalIdQueryExecutionMaxTimeEntityback to summary
public String getNaturalIdQueryExecutionMaxTimeEntity()

Get the entity for the maximum natural id query time

getNaturalIdQueryExecutionMaxTimeRegionback to summary
public String getNaturalIdQueryExecutionMaxTimeRegion()

Get the region for the maximum natural id query time

getNaturalIdStatisticsback to summary
public NaturalIdStatistics getNaturalIdStatistics(String entityName)

Natural id resolution query statistics for an entity type

Parameters
entityName:String

The entity name that is the root of the hierarchy containing the natural id

Returns:NaturalIdStatistics

NaturalIdCacheStatistics

getOptimisticFailureCountback to summary
public long getOptimisticFailureCount()

The number of Hibernate StaleObjectStateExceptions or JPA OptimisticLockExceptions that occurred.

getPrepareStatementCountback to summary
public long getPrepareStatementCount()

The number of prepared statements that were acquired

getQueriesback to summary
public 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.

getQueryCacheHitCountback to summary
public long getQueryCacheHitCount()

Get the global number of cached queries successfully retrieved from cache

getQueryCacheMissCountback to summary
public long getQueryCacheMissCount()

Get the global number of cached queries *not* found in cache

getQueryCachePutCountback to summary
public long getQueryCachePutCount()

Get the global number of cacheable queries put in cache

getQueryExecutionCountback to summary
public long getQueryExecutionCount()

Get global number of executed queries

Returns:long

query execution count

getQueryExecutionMaxTimeback to summary
public long getQueryExecutionMaxTime()

Get the time in milliseconds of the slowest query.

getQueryExecutionMaxTimeQueryStringback to summary
public String getQueryExecutionMaxTimeQueryString()

Get the query string for the slowest query.

getQueryPlanCacheHitCountback to summary
public default long getQueryPlanCacheHitCount()

Get the global number of query plans successfully retrieved from cache

getQueryPlanCacheMissCountback to summary
public default long getQueryPlanCacheMissCount()

Get the global number of query plans lookups *not* found in cache

getQueryRegionStatisticsback to summary
public CacheRegionStatistics getQueryRegionStatistics(String regionName)

Second-level cache statistics per query region

Parameters
regionName:String

The unqualified region name

Returns:CacheRegionStatistics

Stats for the named region, or null if (1) query result caching is not enabled or (2) no query region exists with that name

getQueryStatisticsback to summary
public QueryStatistics getQueryStatistics(String queryString)

Query statistics from query string (HQL or SQL)

Parameters
queryString:String

query string

Returns:QueryStatistics

QueryStatistics

getSecondLevelCacheHitCountback to summary
public long getSecondLevelCacheHitCount()

Global number of cacheable entities/collections successfully retrieved from the cache

getSecondLevelCacheMissCountback to summary
public long getSecondLevelCacheMissCount()

Global number of cacheable entities/collections not found in the cache and loaded from the database.

getSecondLevelCachePutCountback to summary
public long getSecondLevelCachePutCount()

Global number of cacheable entities/collections put in the cache

getSecondLevelCacheRegionNamesback to summary
public 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

getSecondLevelCacheStatisticsback to summary
public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName)

Deprecated

(since 5.3) Use getDomainDataRegionStatistics instead

Second-level cache statistics per region

Parameters
regionName:String

qualified region name

Returns:SecondLevelCacheStatistics

SecondLevelCacheStatistics or null if the second level cache is not enabled

Annotations
@Deprecated
Exceptions
IllegalArgumentException:
if the region name could not be resolved
getSessionCloseCountback to summary
public long getSessionCloseCount()

Global number of sessions closed

getSessionOpenCountback to summary
public long getSessionOpenCount()

Global number of sessions opened

getStartTimeback to summary
public long getStartTime()

The milliseconds (JVM standard System#currentTimeMillis()) since the initial creation of this Statistics instance or the last time clear() was called.

API Note

This time(stamp) is

getSuccessfulTransactionCountback to summary
public long getSuccessfulTransactionCount()

The number of transactions we know to have been successful

getTransactionCountback to summary
public long getTransactionCount()

The number of transactions we know to have completed

getUpdateTimestampsCacheHitCountback to summary
public long getUpdateTimestampsCacheHitCount()

Get the global number of timestamps successfully retrieved from cache

getUpdateTimestampsCacheMissCountback to summary
public long getUpdateTimestampsCacheMissCount()

Get the global number of timestamp requests that were not found in the cache

getUpdateTimestampsCachePutCountback to summary
public long getUpdateTimestampsCachePutCount()

Get the global number of timestamps put in cache

isStatisticsEnabledback to summary
public boolean isStatisticsEnabled()

Are statistics enabled

logSummaryback to summary
public void logSummary()

log in info level the main statistics

setStatisticsEnabledback to summary
public void setStatisticsEnabled(boolean b)

Enable statistics logs (this is a dynamic parameter)