org.hibernate.stat

Class StatisticsImpl

Implemented Interfaces:
Statistics, StatisticsImplementor

public class StatisticsImpl
extends java.lang.Object
implements Statistics, StatisticsImplementor

Author:
Gavin King
See Also:
Statistics

Constructor Summary

StatisticsImpl()
StatisticsImpl(SessionFactoryImplementor sessionFactory)

Method Summary

void
clear()
reset all statistics
void
closeSession()
void
closeStatement()
void
connect()
void
deleteEntity(String entityName)
void
endTransaction(boolean success)
void
fetchCollection(String role)
void
fetchEntity(String entityName)
void
flush()
long
getCloseStatementCount()
The number of prepared statements that were released
long
getCollectionFetchCount()
long
getCollectionLoadCount()
long
getCollectionRecreateCount()
long
getCollectionRemoveCount()
String[]
getCollectionRoleNames()
Get the names of all collection roles
CollectionStatistics
getCollectionStatistics(String role)
Get collection statistics per role
long
getCollectionUpdateCount()
long
getConnectCount()
long
getEntityDeleteCount()
long
getEntityFetchCount()
long
getEntityInsertCount()
long
getEntityLoadCount()
String[]
getEntityNames()
Get the names of all entities
EntityStatistics
getEntityStatistics(String entityName)
find entity statistics per name
long
getEntityUpdateCount()
long
getFlushCount()
long
getOptimisticFailureCount()
The number of StaleObjectStateExceptions 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()
String
getQueryExecutionMaxTimeQueryString()
Get the query string for the slowest query.
QueryStatistics
getQueryStatistics(String queryString)
Query statistics from query string (HQL or SQL)
long
getSecondLevelCacheHitCount()
long
getSecondLevelCacheMissCount()
long
getSecondLevelCachePutCount()
String[]
getSecondLevelCacheRegionNames()
Get all second-level cache region names
SecondLevelCacheStatistics
getSecondLevelCacheStatistics(String regionName)
Second level cache statistics per region
long
getSessionCloseCount()
long
getSessionOpenCount()
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)
boolean
isStatisticsEnabled()
Are statistics logged
void
loadCollection(String role)
void
loadEntity(String entityName)
void
logSummary()
log in info level the main statistics
void
openSession()
void
optimisticFailure(String entityName)
void
prepareStatement()
void
queryCacheHit(String hql, String regionName)
void
queryCacheMiss(String hql, String regionName)
void
queryCachePut(String hql, String regionName)
void
queryExecuted(String hql, int rows, long time)
void
recreateCollection(String role)
void
removeCollection(String role)
void
secondLevelCacheHit(String regionName)
void
secondLevelCacheMiss(String regionName)
void
secondLevelCachePut(String regionName)
void
setStatisticsEnabled(boolean b)
Enable statistics logs (this is a dynamic parameter)
String
toString()
void
updateCollection(String role)
void
updateEntity(String entityName)

Constructor Details

StatisticsImpl

public StatisticsImpl()

StatisticsImpl

public StatisticsImpl(SessionFactoryImplementor sessionFactory)

Method Details

clear

public void clear()
reset all statistics
Specified by:
clear in interface Statistics

closeSession

public void closeSession()
Specified by:
closeSession in interface StatisticsImplementor

closeStatement

public void closeStatement()
Specified by:
closeStatement in interface StatisticsImplementor

connect

public void connect()
Specified by:
connect in interface StatisticsImplementor

deleteEntity

public void deleteEntity(String entityName)
Specified by:
deleteEntity in interface StatisticsImplementor

endTransaction

public void endTransaction(boolean success)
Specified by:
endTransaction in interface StatisticsImplementor

fetchCollection

public void fetchCollection(String role)
Specified by:
fetchCollection in interface StatisticsImplementor

fetchEntity

public void fetchEntity(String entityName)
Specified by:
fetchEntity in interface StatisticsImplementor

flush

public void flush()
Specified by:
flush in interface StatisticsImplementor

getCloseStatementCount

public long getCloseStatementCount()
The number of prepared statements that were released
Specified by:
getCloseStatementCount in interface Statistics

getCollectionFetchCount

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

getCollectionLoadCount

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

getCollectionRecreateCount

public long getCollectionRecreateCount()
Specified by:
getCollectionRecreateCount in interface Statistics
Returns:
collection recreation

getCollectionRemoveCount

public long getCollectionRemoveCount()
Specified by:
getCollectionRemoveCount in interface Statistics
Returns:
collection removal FIXME: even if isInverse="true"?

getCollectionRoleNames

public String[] getCollectionRoleNames()
Get the names of all collection roles
Specified by:
getCollectionRoleNames in interface Statistics

getCollectionStatistics

public CollectionStatistics getCollectionStatistics(String role)
Get collection statistics per role
Specified by:
getCollectionStatistics in interface Statistics
Parameters:
role - collection role
Returns:
CollectionStatistics

getCollectionUpdateCount

public long getCollectionUpdateCount()
Specified by:
getCollectionUpdateCount in interface Statistics
Returns:
collection update

getConnectCount

public long getConnectCount()
Specified by:
getConnectCount in interface Statistics
Returns:
session connect

getEntityDeleteCount

public long getEntityDeleteCount()
Specified by:
getEntityDeleteCount in interface Statistics
Returns:
entity deletion count

getEntityFetchCount

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

getEntityInsertCount

public long getEntityInsertCount()
Specified by:
getEntityInsertCount in interface Statistics
Returns:
entity insertion count

getEntityLoadCount

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

getEntityNames

public String[] getEntityNames()
Get the names of all entities
Specified by:
getEntityNames in interface Statistics

getEntityStatistics

public EntityStatistics getEntityStatistics(String entityName)
find entity statistics per name
Specified by:
getEntityStatistics in interface Statistics
Parameters:
entityName - entity name
Returns:
EntityStatistics object

getEntityUpdateCount

public long getEntityUpdateCount()
Specified by:
getEntityUpdateCount in interface Statistics
Returns:
entity update

getFlushCount

public long getFlushCount()
Specified by:
getFlushCount in interface Statistics
Returns:
flush

getOptimisticFailureCount

public long getOptimisticFailureCount()
The number of StaleObjectStateExceptions that occurred
Specified by:
getOptimisticFailureCount in interface Statistics

getPrepareStatementCount

public long getPrepareStatementCount()
The number of prepared statements that were acquired
Specified by:
getPrepareStatementCount in interface Statistics

getQueries

public String[] getQueries()
Get all executed query strings
Specified by:
getQueries in interface Statistics

getQueryCacheHitCount

public long getQueryCacheHitCount()
Get the global number of cached queries successfully retrieved from cache
Specified by:
getQueryCacheHitCount in interface Statistics

getQueryCacheMissCount

public long getQueryCacheMissCount()
Get the global number of cached queries *not* found in cache
Specified by:
getQueryCacheMissCount in interface Statistics

getQueryCachePutCount

public long getQueryCachePutCount()
Get the global number of cacheable queries put in cache
Specified by:
getQueryCachePutCount in interface Statistics

getQueryExecutionCount

public long getQueryExecutionCount()
Get global number of executed queries
Specified by:
getQueryExecutionCount in interface Statistics
Returns:
query execution count

getQueryExecutionMaxTime

public long getQueryExecutionMaxTime()
Specified by:
getQueryExecutionMaxTime in interface Statistics
Returns:
Returns the max query execution time, for all queries

getQueryExecutionMaxTimeQueryString

public String getQueryExecutionMaxTimeQueryString()
Get the query string for the slowest query.
Specified by:
getQueryExecutionMaxTimeQueryString in interface Statistics

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

getSecondLevelCacheHitCount

public long getSecondLevelCacheHitCount()
Specified by:
getSecondLevelCacheHitCount in interface Statistics
Returns:
second level cache hit

getSecondLevelCacheMissCount

public long getSecondLevelCacheMissCount()
Specified by:
getSecondLevelCacheMissCount in interface Statistics
Returns:
second level cache miss

getSecondLevelCachePutCount

public long getSecondLevelCachePutCount()
Specified by:
getSecondLevelCachePutCount in interface Statistics
Returns:
second level cache put

getSecondLevelCacheRegionNames

public String[] getSecondLevelCacheRegionNames()
Get all second-level cache region names
Specified by:
getSecondLevelCacheRegionNames in interface Statistics

getSecondLevelCacheStatistics

public SecondLevelCacheStatistics getSecondLevelCacheStatistics(String regionName)
Second level cache statistics per region
Specified by:
getSecondLevelCacheStatistics in interface Statistics
Parameters:
regionName - region name
Returns:
SecondLevelCacheStatistics

getSessionCloseCount

public long getSessionCloseCount()
Specified by:
getSessionCloseCount in interface Statistics
Returns:
session closing

getSessionOpenCount

public long getSessionOpenCount()
Specified by:
getSessionOpenCount in interface Statistics
Returns:
session opening

getStartTime

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

getSuccessfulTransactionCount

public long getSuccessfulTransactionCount()
The number of transactions we know to have been successful
Specified by:
getSuccessfulTransactionCount in interface Statistics

getTransactionCount

public long getTransactionCount()
The number of transactions we know to have completed
Specified by:
getTransactionCount in interface Statistics

insertEntity

public void insertEntity(String entityName)
Specified by:
insertEntity in interface StatisticsImplementor

isStatisticsEnabled

public boolean isStatisticsEnabled()
Are statistics logged
Specified by:
isStatisticsEnabled in interface Statistics

loadCollection

public void loadCollection(String role)
Specified by:
loadCollection in interface StatisticsImplementor

loadEntity

public void loadEntity(String entityName)
Specified by:
loadEntity in interface StatisticsImplementor

logSummary

public void logSummary()
log in info level the main statistics
Specified by:
logSummary in interface Statistics

openSession

public void openSession()
Specified by:
openSession in interface StatisticsImplementor

optimisticFailure

public void optimisticFailure(String entityName)
Specified by:
optimisticFailure in interface StatisticsImplementor

prepareStatement

public void prepareStatement()
Specified by:
prepareStatement in interface StatisticsImplementor

queryCacheHit

public void queryCacheHit(String hql,
                          String regionName)
Specified by:
queryCacheHit in interface StatisticsImplementor

queryCacheMiss

public void queryCacheMiss(String hql,
                           String regionName)
Specified by:
queryCacheMiss in interface StatisticsImplementor

queryCachePut

public void queryCachePut(String hql,
                          String regionName)
Specified by:
queryCachePut in interface StatisticsImplementor

queryExecuted

public void queryExecuted(String hql,
                          int rows,
                          long time)
Specified by:
queryExecuted in interface StatisticsImplementor

recreateCollection

public void recreateCollection(String role)
Specified by:
recreateCollection in interface StatisticsImplementor

removeCollection

public void removeCollection(String role)
Specified by:
removeCollection in interface StatisticsImplementor

secondLevelCacheHit

public void secondLevelCacheHit(String regionName)
Specified by:
secondLevelCacheHit in interface StatisticsImplementor

secondLevelCacheMiss

public void secondLevelCacheMiss(String regionName)
Specified by:
secondLevelCacheMiss in interface StatisticsImplementor

secondLevelCachePut

public void secondLevelCachePut(String regionName)
Specified by:
secondLevelCachePut in interface StatisticsImplementor

setStatisticsEnabled

public void setStatisticsEnabled(boolean b)
Enable statistics logs (this is a dynamic parameter)
Specified by:
setStatisticsEnabled in interface Statistics

toString

public String toString()

updateCollection

public void updateCollection(String role)
Specified by:
updateCollection in interface StatisticsImplementor

updateEntity

public void updateEntity(String entityName)
Specified by:
updateEntity in interface StatisticsImplementor