## org.hibernate.stat
Class ConcurrentStatisticsImpl

    java.lang.Object
      org.hibernate.stat.ConcurrentStatisticsImpl

All Implemented Interfaces:
  Statistics, StatisticsImplementor

    public class ConcurrentStatisticsImpl

extends Object
implements Statistics, StatisticsImplementor

Implementation of `Statistics`, as well as `StatisticsImplementor`, based on the `java.util.concurrent` package introduced in Java 5.

Author:
  Alex Snaps

Constructor Summary
`ConcurrentStatisticsImpl()`
`ConcurrentStatisticsImpl(SessionFactoryImplementor sessionFactory)`

Method Summary
`void` `clear()` reset all statistics
`void` `closeSession()` Callback about a session being closed.
`void` `closeStatement()` Callback about a statement being closed.
`void` `connect()` Callback about a connection being obtained from `ConnectionProvider`
`void` `deleteEntity(String entityName)` Callback about an entity being deleted.
`void` `endTransaction(boolean success)` Callback about a transaction completing.
`void` `fetchCollection(String role)` Callback to indicate a collection being fetched.
`void` `fetchEntity(String entityName)` Callback about an entity being fetched.
`void` `flush()` Callback about a flush occurring
`long` `getCloseStatementCount()` The number of prepared statements that were released
`long` `getCollectionFetchCount()` Global number of collections fetched
`long` `getCollectionLoadCount()` Global number of collections loaded
`long` `getCollectionRecreateCount()` Global number of collections recreated
`long` `getCollectionRemoveCount()` Global number of collections removed
`String[]` `getCollectionRoleNames()` Get the names of all collection roles
`CollectionStatistics` `getCollectionStatistics(String role)` Get collection statistics per role
`long` `getCollectionUpdateCount()` Global number of collections updated
`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)
`long` `getEntityDeleteCount()` Get global number of entity deletes
`long` `getEntityFetchCount()` Get global number of entity fetchs
`long` `getEntityInsertCount()` Get global number of entity inserts
`long` `getEntityLoadCount()` Get global number of entity loads
`String[]` `getEntityNames()` Get the names of all entities
`EntityStatistics` `getEntityStatistics(String entityName)` find entity statistics per name
`long` `getEntityUpdateCount()` Get global number of entity updates
`long` `getFlushCount()` Get the global number of flush executed by sessions (either implicit or explicit)
`long` `getOptimisticFailureCount()` The number of `StaleObjectStateException`s that occurred
`long` `getPrepareStatementCount()` The number of prepared statements that were acquired
`String[]` `getQueries()` Get all executed query strings
`long` `getQueryCacheHitCount()` Get the global number of cached queries successfully retrieved from cache
`long` `getQueryCacheMissCount()` Get the global number of cached queries *not* found in cache
`long` `getQueryCachePutCount()` Get the global number of cacheable queries put in cache
`long` `getQueryExecutionCount()` Get global number of executed queries
`long` `getQueryExecutionMaxTime()` Get the time in milliseconds of the slowest query.
`String` `getQueryExecutionMaxTimeQueryString()` Get the query string for the slowest query.
`QueryStatistics` `getQueryStatistics(String queryString)` Query statistics from query string (HQL or SQL)
`long` `getSecondLevelCacheHitCount()` Global number of cacheable entities/collections successfully retrieved from the cache
`long` `getSecondLevelCacheMissCount()` Global number of cacheable entities/collections not found in the cache and loaded from the database.
`long` `getSecondLevelCachePutCount()` Global number of cacheable entities/collections put in the cache
`String[]` `getSecondLevelCacheRegionNames()` Get all second-level cache region names
`SecondLevelCacheStatistics` `getSecondLevelCacheStatistics(String regionName)` Second level cache statistics per region
`long` `getSessionCloseCount()` Global number of sessions closed
`long` `getSessionOpenCount()` Global number of sessions opened
`long` `getStartTime()`
`long` `getSuccessfulTransactionCount()` The number of transactions we know to have been successful
`long` `getTransactionCount()` The number of transactions we know to have completed
`void` `insertEntity(String entityName)` Callback about an entity being inserted
`boolean` `isStatisticsEnabled()` Are statistics logged
`void` `loadCollection(String role)` Callback about a collection loading.
`void` `loadEntity(String entityName)` Callback about an entity being loaded.
`void` `logSummary()` log in info level the main statistics
`void` `openSession()` Callback about a session being opened.
`void` `optimisticFailure(String entityName)` Callback about an optimistic lock failure on an entity
`void` `prepareStatement()` Callback about a statement being prepared.
`void` `queryCacheHit(String hql, String regionName)` Callback indicating a get from the query cache resulted in a hit.
`void` `queryCacheMiss(String hql, String regionName)` Callback indicating a get from the query cache resulted in a miss.
`void` `queryCachePut(String hql, String regionName)` Callback indicating a put into the query cache.
`void` `queryExecuted(String hql, int rows, long time)` Callback indicating execution of a sql/hql query
`void` `recreateCollection(String role)` Callback indicating a collection recreation (full deletion + full (re-)insertion).
`void` `removeCollection(String role)` Callback indicating a collection removal.
`void` `secondLevelCacheHit(String regionName)` Callback indicating a get from second level cache resulted in a hit.
`void` `secondLevelCacheMiss(String regionName)` Callback indicating a get from second level cache resulted in a miss.
`void` `secondLevelCachePut(String regionName)` Callback indicating a put into second level cache.
`void` `setStatisticsEnabled(boolean b)` Enable statistics logs (this is a dynamic parameter)
`String` `toString()`
`void` `updateCollection(String role)` Callback indicating a collection was updated.
`void` `updateEntity(String entityName)` Callback about an entity being updated.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Constructor Detail

### ConcurrentStatisticsImpl

    public ConcurrentStatisticsImpl()

### ConcurrentStatisticsImpl

    public ConcurrentStatisticsImpl(SessionFactoryImplementor sessionFactory)

Method Detail

### clear

    public void clear()

  reset all statistics

  Specified by:
    `clear` in interface `Statistics`

### openSession

    public void openSession()

  Description copied from interface: `StatisticsImplementor`
  Callback about a session being opened.

  Specified by:
    `openSession` in interface `StatisticsImplementor`

### closeSession

    public void closeSession()

  Description copied from interface: `StatisticsImplementor`
  Callback about a session being closed.

  Specified by:
    `closeSession` in interface `StatisticsImplementor`

### flush

    public void flush()

  Description copied from interface: `StatisticsImplementor`
  Callback about a flush occurring

  Specified by:
    `flush` in interface `StatisticsImplementor`

### connect

    public void connect()

  Description copied from interface: `StatisticsImplementor`
  Callback about a connection being obtained from `ConnectionProvider`

  Specified by:
    `connect` in interface `StatisticsImplementor`

### loadEntity

    public void loadEntity(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an entity being loaded. This might indicate a proxy or a fully initialized entity, but in either case it means without a separate SQL query being needed.

  Specified by:
    `loadEntity` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity loaded.

### fetchEntity

    public void fetchEntity(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an entity being fetched. Unlike `StatisticsImplementor.loadEntity(java.lang.String)` this indicates a separate query being performed.

  Specified by:
    `fetchEntity` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity fetched.

### getEntityStatistics

    public EntityStatistics getEntityStatistics(String entityName)

  find entity statistics per name

  Specified by:
    `getEntityStatistics` in interface `Statistics`
  Parameters:
    `entityName` - entity name
  Returns:
    EntityStatistics object

### updateEntity

    public void updateEntity(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an entity being updated.

  Specified by:
    `updateEntity` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity updated.

### insertEntity

    public void insertEntity(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an entity being inserted

  Specified by:
    `insertEntity` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity inserted

### deleteEntity

    public void deleteEntity(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an entity being deleted.

  Specified by:
    `deleteEntity` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity deleted.

### getCollectionStatistics

    public CollectionStatistics getCollectionStatistics(String role)

  Get collection statistics per role

  Specified by:
    `getCollectionStatistics` in interface `Statistics`
  Parameters:
    `role` - collection role
  Returns:
    CollectionStatistics

### loadCollection

    public void loadCollection(String role)

  Description copied from interface: `StatisticsImplementor`
  Callback about a collection loading. This might indicate a lazy collection or an initialized collection being created, but in either case it means without a separate SQL query being needed.

  Specified by:
    `loadCollection` in interface `StatisticsImplementor`
  Parameters:
    `role` - The collection role.

### fetchCollection

    public void fetchCollection(String role)

  Description copied from interface: `StatisticsImplementor`
  Callback to indicate a collection being fetched. Unlike `StatisticsImplementor.loadCollection(java.lang.String)`, this indicates a separate query was needed.

  Specified by:
    `fetchCollection` in interface `StatisticsImplementor`
  Parameters:
    `role` - The collection role.

### updateCollection

    public void updateCollection(String role)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a collection was updated.

  Specified by:
    `updateCollection` in interface `StatisticsImplementor`
  Parameters:
    `role` - The collection role.

### recreateCollection

    public void recreateCollection(String role)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a collection recreation (full deletion + full (re-)insertion).

  Specified by:
    `recreateCollection` in interface `StatisticsImplementor`
  Parameters:
    `role` - The collection role.

### removeCollection

    public void removeCollection(String role)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a collection removal.

  Specified by:
    `removeCollection` in interface `StatisticsImplementor`
  Parameters:
    `role` - The collection role.

### getSecondLevelCacheStatistics

    public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName)

  Second level cache statistics per region

  Specified by:
    `getSecondLevelCacheStatistics` in interface `Statistics`
  Parameters:
    `regionName` - region name
  Returns:
    SecondLevelCacheStatistics

### secondLevelCachePut

    public void secondLevelCachePut(String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a put into second level cache.

  Specified by:
    `secondLevelCachePut` in interface `StatisticsImplementor`
  Parameters:
    `regionName` - The name of the cache region

### secondLevelCacheHit

    public void secondLevelCacheHit(String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a get from second level cache resulted in a hit.

  Specified by:
    `secondLevelCacheHit` in interface `StatisticsImplementor`
  Parameters:
    `regionName` - The name of the cache region

### secondLevelCacheMiss

    public void secondLevelCacheMiss(String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a get from second level cache resulted in a miss.

  Specified by:
    `secondLevelCacheMiss` in interface `StatisticsImplementor`
  Parameters:
    `regionName` - The name of the cache region

### queryExecuted

    public void queryExecuted(String hql,
                              int rows,
                              long time)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating execution of a sql/hql query

  Specified by:
    `queryExecuted` in interface `StatisticsImplementor`
  Parameters:
    `hql` - The query
    `rows` - Number of rows returned
    `time` - execution time

### queryCacheHit

    public void queryCacheHit(String hql,
                              String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a get from the query cache resulted in a hit.

  Specified by:
    `queryCacheHit` in interface `StatisticsImplementor`
  Parameters:
    `hql` - The query
    `regionName` - The name of the cache region

### queryCacheMiss

    public void queryCacheMiss(String hql,
                               String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a get from the query cache resulted in a miss.

  Specified by:
    `queryCacheMiss` in interface `StatisticsImplementor`
  Parameters:
    `hql` - The query
    `regionName` - The name of the cache region

### queryCachePut

    public void queryCachePut(String hql,
                              String regionName)

  Description copied from interface: `StatisticsImplementor`
  Callback indicating a put into the query cache.

  Specified by:
    `queryCachePut` in interface `StatisticsImplementor`
  Parameters:
    `hql` - The query
    `regionName` - The cache region

### getQueryStatistics

    public QueryStatistics getQueryStatistics(String queryString)

  Query statistics from query string (HQL or SQL)

  Specified by:
    `getQueryStatistics` in interface `Statistics`
  Parameters:
    `queryString` - query string
  Returns:
    QueryStatistics

### getEntityDeleteCount

    public long getEntityDeleteCount()

  Description copied from interface: `Statistics`
  Get global number of entity deletes

  Specified by:
    `getEntityDeleteCount` in interface `Statistics`
  Returns:
    entity deletion count

### getEntityInsertCount

    public long getEntityInsertCount()

  Description copied from interface: `Statistics`
  Get global number of entity inserts

  Specified by:
    `getEntityInsertCount` in interface `Statistics`
  Returns:
    entity insertion count

### getEntityLoadCount

    public long getEntityLoadCount()

  Description copied from interface: `Statistics`
  Get global number of entity loads

  Specified by:
    `getEntityLoadCount` in interface `Statistics`
  Returns:
    entity load (from DB)

### getEntityFetchCount

    public long getEntityFetchCount()

  Description copied from interface: `Statistics`
  Get global number of entity fetchs

  Specified by:
    `getEntityFetchCount` in interface `Statistics`
  Returns:
    entity fetch (from DB)

### getEntityUpdateCount

    public long getEntityUpdateCount()

  Description copied from interface: `Statistics`
  Get global number of entity updates

  Specified by:
    `getEntityUpdateCount` in interface `Statistics`
  Returns:
    entity update

### getQueryExecutionCount

    public long getQueryExecutionCount()

  Description copied from interface: `Statistics`
  Get global number of executed queries

  Specified by:
    `getQueryExecutionCount` in interface `Statistics`
  Returns:
    query execution count

### getQueryCacheHitCount

    public long getQueryCacheHitCount()

  Description copied from interface: `Statistics`
  Get the global number of cached queries successfully retrieved from cache

  Specified by:
    `getQueryCacheHitCount` in interface `Statistics`

### getQueryCacheMissCount

    public long getQueryCacheMissCount()

  Description copied from interface: `Statistics`
  Get the global number of cached queries *not* found in cache

  Specified by:
    `getQueryCacheMissCount` in interface `Statistics`

### getQueryCachePutCount

    public long getQueryCachePutCount()

  Description copied from interface: `Statistics`
  Get the global number of cacheable queries put in cache

  Specified by:
    `getQueryCachePutCount` in interface `Statistics`

### getFlushCount

    public long getFlushCount()

  Description copied from interface: `Statistics`
  Get the global number of flush executed by sessions (either implicit or explicit)

  Specified by:
    `getFlushCount` in interface `Statistics`
  Returns:
    flush

### getConnectCount

    public long getConnectCount()

  Description copied from interface: `Statistics`
  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)

  Specified by:
    `getConnectCount` in interface `Statistics`
  Returns:
    session connect

### getSecondLevelCacheHitCount

    public long getSecondLevelCacheHitCount()

  Description copied from interface: `Statistics`
  Global number of cacheable entities/collections successfully retrieved from the cache

  Specified by:
    `getSecondLevelCacheHitCount` in interface `Statistics`
  Returns:
    second level cache hit

### getSecondLevelCacheMissCount

    public long getSecondLevelCacheMissCount()

  Description copied from interface: `Statistics`
  Global number of cacheable entities/collections not found in the cache and loaded from the database.

  Specified by:
    `getSecondLevelCacheMissCount` in interface `Statistics`
  Returns:
    second level cache miss

### getSecondLevelCachePutCount

    public long getSecondLevelCachePutCount()

  Description copied from interface: `Statistics`
  Global number of cacheable entities/collections put in the cache

  Specified by:
    `getSecondLevelCachePutCount` in interface `Statistics`
  Returns:
    second level cache put

### getSessionCloseCount

    public long getSessionCloseCount()

  Description copied from interface: `Statistics`
  Global number of sessions closed

  Specified by:
    `getSessionCloseCount` in interface `Statistics`
  Returns:
    session closing

### getSessionOpenCount

    public long getSessionOpenCount()

  Description copied from interface: `Statistics`
  Global number of sessions opened

  Specified by:
    `getSessionOpenCount` in interface `Statistics`
  Returns:
    session opening

### getCollectionLoadCount

    public long getCollectionLoadCount()

  Description copied from interface: `Statistics`
  Global number of collections loaded

  Specified by:
    `getCollectionLoadCount` in interface `Statistics`
  Returns:
    collection loading (from DB)

### getCollectionFetchCount

    public long getCollectionFetchCount()

  Description copied from interface: `Statistics`
  Global number of collections fetched

  Specified by:
    `getCollectionFetchCount` in interface `Statistics`
  Returns:
    collection fetching (from DB)

### getCollectionUpdateCount

    public long getCollectionUpdateCount()

  Description copied from interface: `Statistics`
  Global number of collections updated

  Specified by:
    `getCollectionUpdateCount` in interface `Statistics`
  Returns:
    collection update

### getCollectionRemoveCount

    public long getCollectionRemoveCount()

  Description copied from interface: `Statistics`
  Global number of collections removed

  Specified by:
    `getCollectionRemoveCount` in interface `Statistics`
  Returns:
    collection removal FIXME: even if isInverse="true"?

### getCollectionRecreateCount

    public long getCollectionRecreateCount()

  Description copied from interface: `Statistics`
  Global number of collections recreated

  Specified by:
    `getCollectionRecreateCount` in interface `Statistics`
  Returns:
    collection recreation

### getStartTime

    public long getStartTime()

  Specified by:
    `getStartTime` in interface `Statistics`
  Returns:
    start time in ms (JVM standards `System.currentTimeMillis()`)

### logSummary

    public void logSummary()

  log in info level the main statistics

  Specified by:
    `logSummary` in interface `Statistics`

### isStatisticsEnabled

    public boolean isStatisticsEnabled()

  Are statistics logged

  Specified by:
    `isStatisticsEnabled` in interface `Statistics`

### setStatisticsEnabled

    public void setStatisticsEnabled(boolean b)

  Enable statistics logs (this is a dynamic parameter)

  Specified by:
    `setStatisticsEnabled` in interface `Statistics`

### getQueryExecutionMaxTime

    public long getQueryExecutionMaxTime()

  Description copied from interface: `Statistics`
  Get the time in milliseconds of the slowest query.

  Specified by:
    `getQueryExecutionMaxTime` in interface `Statistics`
  Returns:
    Returns the max query execution time, for all queries

### getQueries

    public String[] getQueries()

  Get all executed query strings

  Specified by:
    `getQueries` in interface `Statistics`

### getEntityNames

    public String[] getEntityNames()

  Get the names of all entities

  Specified by:
    `getEntityNames` in interface `Statistics`

### getCollectionRoleNames

    public String[] getCollectionRoleNames()

  Get the names of all collection roles

  Specified by:
    `getCollectionRoleNames` in interface `Statistics`

### getSecondLevelCacheRegionNames

    public String[] getSecondLevelCacheRegionNames()

  Get all second-level cache region names

  Specified by:
    `getSecondLevelCacheRegionNames` in interface `Statistics`

### endTransaction

    public void endTransaction(boolean success)

  Description copied from interface: `StatisticsImplementor`
  Callback about a transaction completing.

  Specified by:
    `endTransaction` in interface `StatisticsImplementor`
  Parameters:
    `success` - Was the transaction successful?

### getSuccessfulTransactionCount

    public long getSuccessfulTransactionCount()

  Description copied from interface: `Statistics`
  The number of transactions we know to have been successful

  Specified by:
    `getSuccessfulTransactionCount` in interface `Statistics`

### getTransactionCount

    public long getTransactionCount()

  Description copied from interface: `Statistics`
  The number of transactions we know to have completed

  Specified by:
    `getTransactionCount` in interface `Statistics`

### closeStatement

    public void closeStatement()

  Description copied from interface: `StatisticsImplementor`
  Callback about a statement being closed.

  Specified by:
    `closeStatement` in interface `StatisticsImplementor`

### prepareStatement

    public void prepareStatement()

  Description copied from interface: `StatisticsImplementor`
  Callback about a statement being prepared.

  Specified by:
    `prepareStatement` in interface `StatisticsImplementor`

### getCloseStatementCount

    public long getCloseStatementCount()

  Description copied from interface: `Statistics`
  The number of prepared statements that were released

  Specified by:
    `getCloseStatementCount` in interface `Statistics`

### getPrepareStatementCount

    public long getPrepareStatementCount()

  Description copied from interface: `Statistics`
  The number of prepared statements that were acquired

  Specified by:
    `getPrepareStatementCount` in interface `Statistics`

### optimisticFailure

    public void optimisticFailure(String entityName)

  Description copied from interface: `StatisticsImplementor`
  Callback about an optimistic lock failure on an entity

  Specified by:
    `optimisticFailure` in interface `StatisticsImplementor`
  Parameters:
    `entityName` - The name of the entity.

### getOptimisticFailureCount

    public long getOptimisticFailureCount()

  Description copied from interface: `Statistics`
  The number of `StaleObjectStateException`s that occurred

  Specified by:
    `getOptimisticFailureCount` in interface `Statistics`

### toString

    public String toString()

  Overrides:
    `toString` in class `Object`

### getQueryExecutionMaxTimeQueryString

    public String getQueryExecutionMaxTimeQueryString()

  Description copied from interface: `Statistics`
  Get the query string for the slowest query.

  Specified by:
    `getQueryExecutionMaxTimeQueryString` in interface `Statistics`

Copyright © 2001-2010 Red Hat, Inc. All Rights Reserved.