Top Description Fields Constructors Methods
org.hibernate.stat.internal

public Class StatisticsImpl

extends Object
implements StatisticsImplementor, Service
Class Inheritance
All Implemented Interfaces
org.hibernate.service.Service, java.io.Serializable, org.hibernate.stat.spi.StatisticsImplementor, org.hibernate.stat.Statistics
Imports
java.time.Instant, java.util.ArrayList, .List, .Map, .Objects, java.util.concurrent.ConcurrentHashMap, java.util.concurrent.atomic.AtomicLong, .LongAdder, java.util.function.Function, org.hibernate.boot.spi.SessionFactoryOptions, org.hibernate.cache.spi.CacheImplementor, .QueryResultsCache, .QueryResultsRegion, .Region, org.hibernate.engine.spi.SessionFactoryImplementor, org.hibernate.internal.CoreMessageLogger, org.hibernate.internal.util.NullnessUtil, org.hibernate.metamodel.model.domain.NavigableRole, org.hibernate.metamodel.spi.MappingMetamodelImplementor, org.hibernate.persister.entity.EntityPersister, org.hibernate.service.Service, org.hibernate.stat.Statistics, org.hibernate.stat.spi.StatisticsImplementor, org.checkerframework.checker.initialization.qual.UnknownInitialization, org.checkerframework.checker.nullness.qual.Nullable

Implementation of Statistics based on the java.util.concurrent package.
Authors
Alex Snaps, Sanne Grinovero

Field Summary

Modifier and TypeField and Description
private final String[]
private final String[]
private final CacheImplementor
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final StatsNamedContainer<CollectionStatisticsImpl>
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final StatsNamedContainer<EntityStatisticsImpl>
private final LongAdder
private final LongAdder
private volatile boolean
private final StatsNamedContainer<CacheRegionStatisticsImpl>
l2CacheStatsMap

Keyed by region name

private static final CoreMessageLogger
private final MappingMetamodelImplementor
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final AtomicLong
private volatile @Nullable String
private volatile @Nullable String
private final StatsNamedContainer<NaturalIdStatisticsImpl>
private final LongAdder
private final LongAdder
private final boolean
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final AtomicLong
private volatile @Nullable String
private final LongAdder
private final LongAdder
private final StatsNamedContainer<QueryStatisticsImpl>
queryStatsMap

Keyed by query string

private final boolean
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder
private final Map<String, Long>
slowQueries

Keyed by query SQL

private volatile Instant
private final LongAdder
private final LongAdder
private final LongAdder
private final LongAdder

Constructor Summary

AccessConstructor and Description
public
StatisticsImpl(SessionFactoryImplementor sessionFactory)

Deprecated as a consequence of SessionFactoryImplementor being deprecated.

Method Summary

Modifier and TypeMethod and Description
public void
clear()

Implements org.hibernate.stat.Statistics.clear.

reset all statistics
public void
closeSession()

Implements org.hibernate.stat.spi.StatisticsImplementor.closeSession.

Callback about a session being closed.
public void
closeStatement()

Implements org.hibernate.stat.spi.StatisticsImplementor.closeStatement.

Callback about a statement being closed.
public void
collectionCacheHit(NavigableRole
The collection's "path"
collectionRole
,
String
The name of the cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.collectionCacheHit.

Callback indicating a get from second level cache resulted in a hit.
public void
collectionCacheMiss(NavigableRole
The collection's "path"
collectionRole
,
String
The name of the cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.collectionCacheMiss.

Callback indicating a get from second level cache resulted in a miss.
public void
collectionCachePut(NavigableRole
The collection's "path"
collectionRole
,
String
The name of the cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.collectionCachePut.

Callback indicating a put into second level cache.
private @Nullable CacheRegionStatisticsImpl
public void
private @Nullable CacheRegionStatisticsImpl
public void
deleteEntity(String
The name of the entity deleted.
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.deleteEntity.

Callback about an entity being deleted.
public void
endTransaction(boolean
Was the transaction successful?
success
)

Implements org.hibernate.stat.spi.StatisticsImplementor.endTransaction.

Callback about a transaction completing.
public void
entityCacheHit(NavigableRole entityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.entityCacheHit.

Callback indicating a get from second level cache resulted in a hit.
public void
entityCacheMiss(NavigableRole entityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.entityCacheMiss.

Callback indicating a get from second level cache resulted in a miss.
public void
entityCachePut(NavigableRole entityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.entityCachePut.

Callback indicating a put into second level cache.
public void
fetchCollection(String
The collection role.
role
)

Implements org.hibernate.stat.spi.StatisticsImplementor.fetchCollection.

Callback to indicate a collection being fetched.
public void
fetchEntity(String
The name of the entity fetched.
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.fetchEntity.

Callback about an entity being fetched.
public void
flush()

Implements org.hibernate.stat.spi.StatisticsImplementor.flush.

Callback about a flush occurring
public @Nullable CacheRegionStatisticsImpl
getCacheRegionStatistics(String
The unqualified region name
regionName
)

Implements org.hibernate.stat.Statistics.getCacheRegionStatistics.

Obtain the statistics for either a domain data or query result cache region.
public long
getCloseStatementCount()

Implements org.hibernate.stat.Statistics.getCloseStatementCount.

The number of prepared statements that were released.
public long
getCollectionFetchCount()

Implements org.hibernate.stat.Statistics.getCollectionFetchCount.

The global number of collections fetched.
public long
getCollectionLoadCount()

Implements org.hibernate.stat.Statistics.getCollectionLoadCount.

The global number of collections loaded.
public long
getCollectionRecreateCount()

Implements org.hibernate.stat.Statistics.getCollectionRecreateCount.

The global number of collections recreated
public long
getCollectionRemoveCount()

Implements org.hibernate.stat.Statistics.getCollectionRemoveCount.

The global number of collections removed.
public String[]
getCollectionRoleNames()

Implements org.hibernate.stat.Statistics.getCollectionRoleNames.

The names of all collection roles.
public CollectionStatisticsImpl
getCollectionStatistics(String
the collection role
role
)

Implements org.hibernate.stat.Statistics.getCollectionStatistics.

Obtain the statistics for the collection with the given role.
public long
getCollectionUpdateCount()

Implements org.hibernate.stat.Statistics.getCollectionUpdateCount.

The global number of collections updated.
public long
getConnectCount()

Implements org.hibernate.stat.Statistics.getConnectCount.

The global number of connections requested by sessions.
public CacheRegionStatisticsImpl
getDomainDataRegionStatistics(String
The unqualified region name
regionName
)

Implements org.hibernate.stat.Statistics.getDomainDataRegionStatistics.

Obtain the second-level cache statistics for the given cache region.
public long
getEntityDeleteCount()

Implements org.hibernate.stat.Statistics.getEntityDeleteCount.

The global number of entity deletes.
public long
getEntityFetchCount()

Implements org.hibernate.stat.Statistics.getEntityFetchCount.

The global number of entity fetches.
public long
getEntityInsertCount()

Implements org.hibernate.stat.Statistics.getEntityInsertCount.

The global number of entity inserts.
public long
getEntityLoadCount()

Implements org.hibernate.stat.Statistics.getEntityLoadCount.

The global number of entity loads.
public String[]
getEntityNames()

Implements org.hibernate.stat.Statistics.getEntityNames.

The names of all entities.
public EntityStatisticsImpl
getEntityStatistics(String
the entity name
entityName
)

Implements org.hibernate.stat.Statistics.getEntityStatistics.

Obtain the statistics for the entity with the given name.
public long
getEntityUpdateCount()

Implements org.hibernate.stat.Statistics.getEntityUpdateCount.

The global number of entity updates.
public long
getFlushCount()

Implements org.hibernate.stat.Statistics.getFlushCount.

The global number of flush operations executed, including automatic (either manual or automatic).
public long
getNaturalIdCacheHitCount()

Implements org.hibernate.stat.Statistics.getNaturalIdCacheHitCount.

The global number of cached natural id lookups successfully retrieved from the cache.
public long
getNaturalIdCacheMissCount()

Implements org.hibernate.stat.Statistics.getNaturalIdCacheMissCount.

The global number of cached natural id lookups not found in the cache.
public long
getNaturalIdCachePutCount()

Implements org.hibernate.stat.Statistics.getNaturalIdCachePutCount.

The global number of cacheable natural id lookups put in cache.
public long
getNaturalIdQueryExecutionCount()

Implements org.hibernate.stat.Statistics.getNaturalIdQueryExecutionCount.

The global number of natural id queries executed against the database.
public long
getNaturalIdQueryExecutionMaxTime()

Implements org.hibernate.stat.Statistics.getNaturalIdQueryExecutionMaxTime.

The global maximum query time for natural id queries executed against the database.
public @Nullable String
public @Nullable String
public NaturalIdStatisticsImpl
getNaturalIdStatistics(String
The entity name that is the root of the hierarchy containing the natural id
rootEntityName
)

Implements org.hibernate.stat.Statistics.getNaturalIdStatistics.

Obtain the natural id resolution statistics for the entity type with the given name.
public long
getOptimisticFailureCount()

Implements org.hibernate.stat.Statistics.getOptimisticFailureCount.

The number of Hibernate StaleObjectStateExceptions or JPA OptimisticLockExceptions that have occurred.
public long
getPrepareStatementCount()

Implements org.hibernate.stat.Statistics.getPrepareStatementCount.

The number of prepared statements that were acquired.
public String[]
getQueries()

Implements org.hibernate.stat.Statistics.getQueries.

All executed query strings.
public long
getQueryCacheHitCount()

Implements org.hibernate.stat.Statistics.getQueryCacheHitCount.

The global number of cached queries successfully retrieved from the cache.
public long
getQueryCacheMissCount()

Implements org.hibernate.stat.Statistics.getQueryCacheMissCount.

The global number of cached queries notnot found in the cache.
public long
getQueryCachePutCount()

Implements org.hibernate.stat.Statistics.getQueryCachePutCount.

The global number of cacheable queries put in cache.
public long
getQueryExecutionCount()

Implements org.hibernate.stat.Statistics.getQueryExecutionCount.

The global number of executed queries.
public long
getQueryExecutionMaxTime()

Implements org.hibernate.stat.Statistics.getQueryExecutionMaxTime.

The time in milliseconds of the slowest query.
public @Nullable String
public long
getQueryPlanCacheHitCount()

Implements org.hibernate.stat.Statistics.getQueryPlanCacheHitCount.

The global number of query plans successfully retrieved from cache.
public long
getQueryPlanCacheMissCount()

Implements org.hibernate.stat.Statistics.getQueryPlanCacheMissCount.

The global number of query plans lookups not found in cache.
public @Nullable CacheRegionStatisticsImpl
getQueryRegionStatistics(final String
The unqualified region name
regionName
)

Implements org.hibernate.stat.Statistics.getQueryRegionStatistics.

Obtain the second-level cache statistics for the given query cache region.
private CacheRegionStatisticsImpl
public QueryStatisticsImpl
getQueryStatistics(String
the query string, written in HQL or SQL
queryString
)

Implements org.hibernate.stat.Statistics.getQueryStatistics.

Obtain the query statistics for the given query string.
public long
getSecondLevelCacheHitCount()

Implements org.hibernate.stat.Statistics.getSecondLevelCacheHitCount.

The global number of cacheable entities and collections successfully retrieved from the cache.
public long
getSecondLevelCacheMissCount()

Implements org.hibernate.stat.Statistics.getSecondLevelCacheMissCount.

The global number of cacheable entities collections not found in the cache and loaded from the database.
public long
getSecondLevelCachePutCount()

Implements org.hibernate.stat.Statistics.getSecondLevelCachePutCount.

The global number of cacheable entities and collections put in the cache.
public String[]
public long
getSessionCloseCount()

Implements org.hibernate.stat.Statistics.getSessionCloseCount.

The global number of sessions closed.
public long
getSessionOpenCount()

Implements org.hibernate.stat.Statistics.getSessionOpenCount.

The global number of sessions opened.
public Map<String, Long>
getSlowQueries()

Overrides default org.hibernate.stat.spi.StatisticsImplementor.getSlowQueries.

If hibernate.log_slow_query is enabled, a map from the SQL query to the maximum execution time in milliseconds.
public Instant
getStart()

Implements org.hibernate.stat.Statistics.getStart.

The Instant at which this instance of Statistics was created, or since the last time clear() was called.
public long
getStartTime()

Implements org.hibernate.stat.Statistics.getStartTime.

The Instant#toEpochMilli() milliseconds since the initial creation of this instance, or since the last time clear() was called.
public long
getSuccessfulTransactionCount()

Implements org.hibernate.stat.Statistics.getSuccessfulTransactionCount.

The number of transactions we know to have been successful.
public long
getTransactionCount()

Implements org.hibernate.stat.Statistics.getTransactionCount.

The number of transactions we know to have completed.
public long
getUpdateTimestampsCacheHitCount()

Implements org.hibernate.stat.Statistics.getUpdateTimestampsCacheHitCount.

The global number of timestamps successfully retrieved from cache.
public long
getUpdateTimestampsCacheMissCount()

Implements org.hibernate.stat.Statistics.getUpdateTimestampsCacheMissCount.

The global number of timestamp requests that were not found in the cache.
public long
public void
insertEntity(String
The name of the entity inserted
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.insertEntity.

Callback about an entity being inserted
private CacheRegionStatisticsImpl
private CacheRegionStatisticsImpl
private CollectionStatisticsImpl
private EntityStatisticsImpl
private NaturalIdStatisticsImpl
public boolean
isStatisticsEnabled()

Implements org.hibernate.stat.Statistics.isStatisticsEnabled.

Is collection of statistics enabled?
public void
loadCollection(String
The collection role.
role
)

Implements org.hibernate.stat.spi.StatisticsImplementor.loadCollection.

Callback about a collection loading.
public void
loadEntity(String
The name of the entity loaded.
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.loadEntity.

Callback about an entity being loaded.
public void
logSummary()

Implements org.hibernate.stat.Statistics.logSummary.

Log the main statistics at level INFO.
public void
naturalIdCacheHit(NavigableRole rootEntityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.naturalIdCacheHit.

Callback indicating a get from natural id cache resulted in a hit.
public void
naturalIdCacheMiss(NavigableRole rootEntityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.naturalIdCacheMiss.

Callback indicating a get from natural id cache resulted in a miss.
public void
naturalIdCachePut(NavigableRole rootEntityName, String regionName)

Implements org.hibernate.stat.spi.StatisticsImplementor.naturalIdCachePut.

Callback indicating a put into natural id cache.
public void
naturalIdQueryExecuted(String rootEntityName, long time)

Implements org.hibernate.stat.spi.StatisticsImplementor.naturalIdQueryExecuted.

Callback indicating execution of a natural id query
public void
openSession()

Implements org.hibernate.stat.spi.StatisticsImplementor.openSession.

Callback about a session being opened.
public void
optimisticFailure(String
The name of the entity.
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.optimisticFailure.

Callback about an optimistic lock failure on an entity
public void
prepareStatement()

Implements org.hibernate.stat.spi.StatisticsImplementor.prepareStatement.

Callback about a statement being prepared.
public void
queryCacheHit(String
The query
hql
,
String
The name of the cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.queryCacheHit.

Callback indicating a get from the query cache resulted in a hit.
public void
queryCacheMiss(String
The query
hql
,
String
The name of the cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.queryCacheMiss.

Callback indicating a get from the query cache resulted in a miss.
public void
queryCachePut(String
The query
hql
,
String
The cache region
regionName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.queryCachePut.

Callback indicating a put into the query cache.
public void
queryCompiled(String
The query
hql
,
long
execution time
microseconds
)

Overrides default org.hibernate.stat.spi.StatisticsImplementor.queryCompiled.

Callback indicating compilation of a sql/hql query
public void
queryExecuted(String
The query
hql
,
int
Number of rows returned
rows
,
long
execution time
time
)

Implements org.hibernate.stat.spi.StatisticsImplementor.queryExecuted.

Callback indicating execution of a sql/hql query
public void
queryPlanCacheHit(String
The query
query
)

Overrides default org.hibernate.stat.spi.StatisticsImplementor.queryPlanCacheHit.

Callback indicating a get from the query plan cache resulted in a hit.
public void
queryPlanCacheMiss(String
The query
query
)

Overrides default org.hibernate.stat.spi.StatisticsImplementor.queryPlanCacheMiss.

Callback indicating a get from the query plan cache resulted in a miss.
public void
recreateCollection(String
The collection role.
role
)

Implements org.hibernate.stat.spi.StatisticsImplementor.recreateCollection.

Callback indicating a collection recreation (full deletion + full (re-)insertion).
public void
removeCollection(String
The collection role.
role
)

Implements org.hibernate.stat.spi.StatisticsImplementor.removeCollection.

Callback indicating a collection removal.
private void
public void
setStatisticsEnabled(boolean enabled)

Implements org.hibernate.stat.Statistics.setStatisticsEnabled.

Enable or disable statistics collection.
public void
slowQuery(String sql, long executionTime)

Overrides default org.hibernate.stat.spi.StatisticsImplementor.slowQuery.

Register the execution of a slow SQL query.
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
updateCollection(String
The collection role.
role
)

Implements org.hibernate.stat.spi.StatisticsImplementor.updateCollection.

Callback indicating a collection was updated.
public void
updateEntity(String
The name of the entity updated.
entityName
)

Implements org.hibernate.stat.spi.StatisticsImplementor.updateEntity.

Callback about an entity being updated.
public void
updateTimestampsCacheHit()

Implements org.hibernate.stat.spi.StatisticsImplementor.updateTimestampsCacheHit.

Callback indicating a hit to the timestamp cache
public void
updateTimestampsCacheMiss()

Implements org.hibernate.stat.spi.StatisticsImplementor.updateTimestampsCacheMiss.

Callback indicating a miss to the timestamp cache
public void
updateTimestampsCachePut()

Implements org.hibernate.stat.spi.StatisticsImplementor.updateTimestampsCachePut.

Callback indicating a put to the timestamp cache
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait