HHH-18907 fix weird way of enabling logging of session metric
hibernate.session.events.log is now obsolete also deprecate obsolete BaseSessionEventListener class
This commit is contained in:
parent
a1b4773496
commit
c9fa8aabab
|
@ -5,97 +5,14 @@
|
||||||
package org.hibernate;
|
package org.hibernate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A no-op implementation of SessionEventListener. Intended as a convenient base class for developing
|
* A noop implementation of {@link SessionEventListener}.
|
||||||
* SessionEventListener implementations.
|
* Intended as a convenient base class for developing
|
||||||
|
* {@code SessionEventListener} implementations.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
|
*
|
||||||
|
* @deprecated Just implement {@link SessionEventListener} directly.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated(since = "7", forRemoval = true)
|
||||||
public class BaseSessionEventListener implements SessionEventListener {
|
public class BaseSessionEventListener implements SessionEventListener {
|
||||||
@Override
|
|
||||||
public void transactionCompletion(boolean successful) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcConnectionAcquisitionStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcConnectionAcquisitionEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcConnectionReleaseStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcConnectionReleaseEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcPrepareStatementStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcPrepareStatementEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcExecuteStatementStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcExecuteStatementEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcExecuteBatchStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void jdbcExecuteBatchEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cachePutStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cachePutEnd() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cacheGetStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cacheGetEnd(boolean hit) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flushStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void flushEnd(int numberOfEntities, int numberOfCollections) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void partialFlushStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void partialFlushEnd(int numberOfEntities, int numberOfCollections) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dirtyCalculationStart() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dirtyCalculationEnd(boolean dirty) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void end() {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import java.io.Serializable;
|
||||||
* sessions may be registered using the configuration property
|
* sessions may be registered using the configuration property
|
||||||
* {@value org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER}.
|
* {@value org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER}.
|
||||||
* A new instance of the class will be created for each new session.
|
* A new instance of the class will be created for each new session.
|
||||||
* <p>
|
*
|
||||||
* <em>This an incubating API, subject to change.</em>
|
* @apiNote This an incubating API, subject to change.
|
||||||
*
|
*
|
||||||
* @see org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER
|
* @see org.hibernate.cfg.AvailableSettings#AUTO_SESSION_EVENTS_LISTENER
|
||||||
* @see SessionBuilder#eventListeners(SessionEventListener...)
|
* @see SessionBuilder#eventListeners(SessionEventListener...)
|
||||||
|
|
|
@ -100,7 +100,6 @@ import static org.hibernate.cfg.AvailableSettings.IN_CLAUSE_PARAMETER_PADDING;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JDBC_TIME_ZONE;
|
import static org.hibernate.cfg.AvailableSettings.JDBC_TIME_ZONE;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED;
|
import static org.hibernate.cfg.AvailableSettings.JPA_CALLBACKS_ENABLED;
|
||||||
import static org.hibernate.cfg.AvailableSettings.JTA_TRACK_BY_THREAD;
|
import static org.hibernate.cfg.AvailableSettings.JTA_TRACK_BY_THREAD;
|
||||||
import static org.hibernate.cfg.AvailableSettings.LOG_SESSION_METRICS;
|
|
||||||
import static org.hibernate.cfg.AvailableSettings.MAX_FETCH_DEPTH;
|
import static org.hibernate.cfg.AvailableSettings.MAX_FETCH_DEPTH;
|
||||||
import static org.hibernate.cfg.AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER;
|
import static org.hibernate.cfg.AvailableSettings.MULTI_TENANT_IDENTIFIER_RESOLVER;
|
||||||
import static org.hibernate.cfg.AvailableSettings.ORDER_INSERTS;
|
import static org.hibernate.cfg.AvailableSettings.ORDER_INSERTS;
|
||||||
|
@ -357,8 +356,7 @@ public class SessionFactoryOptionsBuilder implements SessionFactoryOptions {
|
||||||
? null
|
? null
|
||||||
: strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName );
|
: strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName );
|
||||||
|
|
||||||
final boolean logSessionMetrics = configurationService.getSetting( LOG_SESSION_METRICS, BOOLEAN, statisticsEnabled );
|
this.baselineSessionEventsListenerBuilder = new BaselineSessionEventsListenerBuilder( autoSessionEventsListener );
|
||||||
this.baselineSessionEventsListenerBuilder = new BaselineSessionEventsListenerBuilder( logSessionMetrics, autoSessionEventsListener );
|
|
||||||
|
|
||||||
this.customEntityDirtinessStrategy = strategySelector.resolveDefaultableStrategy(
|
this.customEntityDirtinessStrategy = strategySelector.resolveDefaultableStrategy(
|
||||||
CustomEntityDirtinessStrategy.class,
|
CustomEntityDirtinessStrategy.class,
|
||||||
|
|
|
@ -84,6 +84,7 @@ public interface SecondLevelCacheLogger extends BasicLogger {
|
||||||
" You can disable this warning by setting '%2$s' to '%3$s'.",
|
" You can disable this warning by setting '%2$s' to '%3$s'.",
|
||||||
id = NAMESPACE + 6
|
id = NAMESPACE + 6
|
||||||
)
|
)
|
||||||
|
@SuppressWarnings( "unused" ) // used by hibernate-jcache
|
||||||
void missingCacheCreated(String regionName, String configurationPropertyToDisableKey, String configurationPropertyToDisableValue);
|
void missingCacheCreated(String regionName, String configurationPropertyToDisableKey, String configurationPropertyToDisableValue);
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
|
@ -92,6 +93,7 @@ public interface SecondLevelCacheLogger extends BasicLogger {
|
||||||
" Update your configuration to rename cache [%2$s] to [%1$s].",
|
" Update your configuration to rename cache [%2$s] to [%1$s].",
|
||||||
id = NAMESPACE + 7
|
id = NAMESPACE + 7
|
||||||
)
|
)
|
||||||
|
@SuppressWarnings( "unused" ) // used by hibernate-jcache
|
||||||
void usingLegacyCacheName(String currentName, String legacyName);
|
void usingLegacyCacheName(String currentName, String legacyName);
|
||||||
|
|
||||||
@LogMessage(level = WARN)
|
@LogMessage(level = WARN)
|
||||||
|
@ -100,6 +102,7 @@ public interface SecondLevelCacheLogger extends BasicLogger {
|
||||||
" Make sure your cache implementation supports JTA transactions.",
|
" Make sure your cache implementation supports JTA transactions.",
|
||||||
id = NAMESPACE + 8
|
id = NAMESPACE + 8
|
||||||
)
|
)
|
||||||
|
@SuppressWarnings( "unused" ) // used by hibernate-jcache
|
||||||
void nonStandardSupportForAccessType(String key, String accessType, String regionName);
|
void nonStandardSupportForAccessType(String key, String accessType, String regionName);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,7 +134,6 @@ public interface PersistenceSettings {
|
||||||
*
|
*
|
||||||
* @see #SCANNER
|
* @see #SCANNER
|
||||||
* @see org.hibernate.boot.archive.scan.spi.Scanner
|
* @see org.hibernate.boot.archive.scan.spi.Scanner
|
||||||
* @see org.hibernate.boot.archive.scan.spi.AbstractScannerImpl
|
|
||||||
* @see org.hibernate.boot.MetadataBuilder#applyArchiveDescriptorFactory
|
* @see org.hibernate.boot.MetadataBuilder#applyArchiveDescriptorFactory
|
||||||
*/
|
*/
|
||||||
String SCANNER_ARCHIVE_INTERPRETER = "hibernate.archive.interpreter";
|
String SCANNER_ARCHIVE_INTERPRETER = "hibernate.archive.interpreter";
|
||||||
|
|
|
@ -13,18 +13,6 @@ import org.hibernate.Interceptor;
|
||||||
*/
|
*/
|
||||||
public interface SessionEventSettings {
|
public interface SessionEventSettings {
|
||||||
|
|
||||||
/**
|
|
||||||
* Controls whether {@linkplain org.hibernate.stat.SessionStatistics session metrics}
|
|
||||||
* should be {@linkplain org.hibernate.engine.internal.StatisticalLoggingSessionEventListener
|
|
||||||
* logged} for any session in which statistics are being collected.
|
|
||||||
* <p>
|
|
||||||
* By default, logging of session metrics is disabled unless {@link StatisticsSettings#GENERATE_STATISTICS}
|
|
||||||
* is enabled.
|
|
||||||
*
|
|
||||||
* @settingDefault Defined by {@link StatisticsSettings#GENERATE_STATISTICS}
|
|
||||||
*/
|
|
||||||
String LOG_SESSION_METRICS = "hibernate.session.events.log";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines a default {@link org.hibernate.SessionEventListener} to be applied to
|
* Defines a default {@link org.hibernate.SessionEventListener} to be applied to
|
||||||
* newly-opened {@link org.hibernate.Session}s.
|
* newly-opened {@link org.hibernate.Session}s.
|
||||||
|
@ -75,4 +63,12 @@ public interface SessionEventSettings {
|
||||||
* @since 5.2
|
* @since 5.2
|
||||||
*/
|
*/
|
||||||
String SESSION_SCOPED_INTERCEPTOR = "hibernate.session_factory.session_scoped_interceptor";
|
String SESSION_SCOPED_INTERCEPTOR = "hibernate.session_factory.session_scoped_interceptor";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated This setting is now ignored. Enable the log category
|
||||||
|
* {@code org.hibernate.session.metrics} to automatically
|
||||||
|
* collect and log session-level metrics.
|
||||||
|
*/
|
||||||
|
@Deprecated(since = "7", forRemoval = true)
|
||||||
|
String LOG_SESSION_METRICS = "hibernate.session.events.log";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,17 +4,18 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.engine.internal;
|
package org.hibernate.engine.internal;
|
||||||
|
|
||||||
import org.hibernate.BaseSessionEventListener;
|
import org.hibernate.SessionEventListener;
|
||||||
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.hibernate.cfg.AvailableSettings#LOG_SESSION_METRICS
|
* Tracks and logs certain session-level metrics.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class StatisticalLoggingSessionEventListener extends BaseSessionEventListener {
|
public class StatisticalLoggingSessionEventListener implements SessionEventListener {
|
||||||
private static final Logger log = Logger.getLogger( StatisticalLoggingSessionEventListener.class );
|
private static final CoreMessageLogger log = messageLogger( "org.hibernate.session.metrics" );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by SettingsFactory (in conjunction with stats being enabled) to determine whether to apply this listener
|
* Used by SettingsFactory (in conjunction with stats being enabled) to determine whether to apply this listener
|
||||||
|
@ -22,7 +23,7 @@ public class StatisticalLoggingSessionEventListener extends BaseSessionEventList
|
||||||
* @return {@code true} if logging is enabled for this listener.
|
* @return {@code true} if logging is enabled for this listener.
|
||||||
*/
|
*/
|
||||||
public static boolean isLoggingEnabled() {
|
public static boolean isLoggingEnabled() {
|
||||||
return log.isInfoEnabled();
|
return log.isDebugEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cumulative state ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// cumulative state ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -274,21 +275,8 @@ public class StatisticalLoggingSessionEventListener extends BaseSessionEventList
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void end() {
|
public void end() {
|
||||||
if ( log.isInfoEnabled() ) {
|
if ( isLoggingEnabled() ) {
|
||||||
log.infof(
|
log.sessionMetrics(
|
||||||
"Session Metrics {\n" +
|
|
||||||
" %s nanoseconds spent acquiring %s JDBC connections;\n" +
|
|
||||||
" %s nanoseconds spent releasing %s JDBC connections;\n" +
|
|
||||||
" %s nanoseconds spent preparing %s JDBC statements;\n" +
|
|
||||||
" %s nanoseconds spent executing %s JDBC statements;\n" +
|
|
||||||
" %s nanoseconds spent executing %s JDBC batches;\n" +
|
|
||||||
" %s nanoseconds spent performing %s L2C puts;\n" +
|
|
||||||
" %s nanoseconds spent performing %s L2C hits;\n" +
|
|
||||||
" %s nanoseconds spent performing %s L2C misses;\n" +
|
|
||||||
" %s nanoseconds spent executing %s flushes (flushing a total of %s entities and %s collections);\n" +
|
|
||||||
" %s nanoseconds spent executing %s pre-partial-flushes;\n" +
|
|
||||||
" %s nanoseconds spent executing %s partial-flushes (flushing a total of %s entities and %s collections)\n" +
|
|
||||||
"}",
|
|
||||||
jdbcConnectionAcquisitionTime,
|
jdbcConnectionAcquisitionTime,
|
||||||
jdbcConnectionAcquisitionCount,
|
jdbcConnectionAcquisitionCount,
|
||||||
jdbcConnectionReleaseTime,
|
jdbcConnectionReleaseTime,
|
||||||
|
|
|
@ -19,21 +19,12 @@ public class BaselineSessionEventsListenerBuilder {
|
||||||
|
|
||||||
private static final SessionEventListener[] EMPTY = new SessionEventListener[0];
|
private static final SessionEventListener[] EMPTY = new SessionEventListener[0];
|
||||||
|
|
||||||
private final boolean logSessionMetrics;
|
|
||||||
private final Class<? extends SessionEventListener> autoListener;
|
private final Class<? extends SessionEventListener> autoListener;
|
||||||
|
|
||||||
public BaselineSessionEventsListenerBuilder(
|
public BaselineSessionEventsListenerBuilder(Class<? extends SessionEventListener> autoListener) {
|
||||||
boolean logSessionMetrics,
|
|
||||||
Class<? extends SessionEventListener> autoListener) {
|
|
||||||
this.logSessionMetrics = logSessionMetrics;
|
|
||||||
this.autoListener = autoListener;
|
this.autoListener = autoListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
public boolean isLogSessionMetrics() {
|
|
||||||
return logSessionMetrics;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
public Class<? extends SessionEventListener> getAutoListener() {
|
public Class<? extends SessionEventListener> getAutoListener() {
|
||||||
return autoListener;
|
return autoListener;
|
||||||
|
@ -48,25 +39,27 @@ public class BaselineSessionEventsListenerBuilder {
|
||||||
}
|
}
|
||||||
|
|
||||||
public SessionEventListener[] buildBaseline() {
|
public SessionEventListener[] buildBaseline() {
|
||||||
final boolean addStats = logSessionMetrics && StatisticalLoggingSessionEventListener.isLoggingEnabled();
|
|
||||||
final boolean addAutoListener = autoListener != null;
|
|
||||||
final SessionEventListener[] arr;
|
final SessionEventListener[] arr;
|
||||||
if ( addStats && addAutoListener ) {
|
if ( autoListener != null ) {
|
||||||
|
if ( StatisticalLoggingSessionEventListener.isLoggingEnabled() ) {
|
||||||
arr = new SessionEventListener[2];
|
arr = new SessionEventListener[2];
|
||||||
arr[0] = buildStatsListener();
|
arr[0] = buildStatsListener();
|
||||||
arr[1] = buildAutoListener( autoListener );
|
arr[1] = buildAutoListener( autoListener );
|
||||||
}
|
}
|
||||||
else if ( !addStats && addAutoListener ) {
|
else {
|
||||||
arr = new SessionEventListener[1];
|
arr = new SessionEventListener[1];
|
||||||
arr[0] = buildAutoListener( autoListener );
|
arr[0] = buildAutoListener( autoListener );
|
||||||
}
|
}
|
||||||
else if ( addStats && !addAutoListener ) {
|
}
|
||||||
|
else {
|
||||||
|
if ( StatisticalLoggingSessionEventListener.isLoggingEnabled() ) {
|
||||||
arr = new SessionEventListener[1];
|
arr = new SessionEventListener[1];
|
||||||
arr[0] = buildStatsListener();
|
arr[0] = buildStatsListener();
|
||||||
}
|
}
|
||||||
else {//if ( !addStats && !addAutoListener )
|
else {
|
||||||
arr = EMPTY;
|
arr = EMPTY;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return arr;
|
return arr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -887,4 +887,50 @@ public interface CoreMessageLogger extends BasicLogger {
|
||||||
value = "Encountered multiple persistence-unit stanzas defining same name [%s]; persistence-unit names must be unique"
|
value = "Encountered multiple persistence-unit stanzas defining same name [%s]; persistence-unit names must be unique"
|
||||||
)
|
)
|
||||||
void duplicatedPersistenceUnitName(String name);
|
void duplicatedPersistenceUnitName(String name);
|
||||||
|
|
||||||
|
@LogMessage(level = DEBUG)
|
||||||
|
@Message(
|
||||||
|
id = 425,
|
||||||
|
value = """
|
||||||
|
Logging session metrics:
|
||||||
|
%s ns acquiring %s JDBC connections
|
||||||
|
%s ns releasing %s JDBC connections
|
||||||
|
%s ns preparing %s JDBC statements
|
||||||
|
%s ns executing %s JDBC statements
|
||||||
|
%s ns executing %s JDBC batches
|
||||||
|
%s ns performing %s second-level cache puts
|
||||||
|
%s ns performing %s second-level cache hits
|
||||||
|
%s ns performing %s second-level cache misses
|
||||||
|
%s ns executing %s flushes (flushing a total of %s entities and %s collections)
|
||||||
|
%s ns executing %s pre-partial-flushes
|
||||||
|
%s ns executing %s partial-flushes (flushing a total of %s entities and %s collections)
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
void sessionMetrics(
|
||||||
|
long jdbcConnectionAcquisitionTime,
|
||||||
|
int jdbcConnectionAcquisitionCount,
|
||||||
|
long jdbcConnectionReleaseTime,
|
||||||
|
int jdbcConnectionReleaseCount,
|
||||||
|
long jdbcPrepareStatementTime,
|
||||||
|
int jdbcPrepareStatementCount,
|
||||||
|
long jdbcExecuteStatementTime,
|
||||||
|
int jdbcExecuteStatementCount,
|
||||||
|
long jdbcExecuteBatchTime,
|
||||||
|
int jdbcExecuteBatchCount,
|
||||||
|
long cachePutTime,
|
||||||
|
int cachePutCount,
|
||||||
|
long cacheHitTime,
|
||||||
|
int cacheHitCount,
|
||||||
|
long cacheMissTime,
|
||||||
|
int cacheMissCount,
|
||||||
|
long flushTime,
|
||||||
|
int flushCount,
|
||||||
|
long flushEntityCount,
|
||||||
|
long flushCollectionCount,
|
||||||
|
long prePartialFlushTime,
|
||||||
|
int prePartialFlushCount,
|
||||||
|
long partialFlushTime,
|
||||||
|
int partialFlushCount,
|
||||||
|
long partialFlushEntityCount,
|
||||||
|
long partialFlushCollectionCount);
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
||||||
*/
|
*/
|
||||||
public class StatisticsImpl implements StatisticsImplementor, Service {
|
public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = messageLogger( StatisticsImpl.class );
|
private static final CoreMessageLogger log = messageLogger( StatisticsImpl.class );
|
||||||
|
|
||||||
private final MappingMetamodelImplementor metamodel;
|
private final MappingMetamodelImplementor metamodel;
|
||||||
private final CacheImplementor cache;
|
private final CacheImplementor cache;
|
||||||
|
@ -702,7 +702,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryExecuted(String hql, int rows, long time) {
|
public void queryExecuted(String hql, int rows, long time) {
|
||||||
LOG.hql( hql, time, (long) rows );
|
log.hql( hql, time, (long) rows );
|
||||||
queryExecutionCount.increment();
|
queryExecutionCount.increment();
|
||||||
|
|
||||||
boolean isLongestQuery;
|
boolean isLongestQuery;
|
||||||
|
@ -724,7 +724,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryCacheHit(String hql, String regionName) {
|
public void queryCacheHit(String hql, String regionName) {
|
||||||
LOG.tracef( "Statistics#queryCacheHit( `%s`, `%s` )", hql, regionName );
|
log.tracef( "Statistics#queryCacheHit( `%s`, `%s` )", hql, regionName );
|
||||||
|
|
||||||
queryCacheHitCount.increment();
|
queryCacheHitCount.increment();
|
||||||
|
|
||||||
|
@ -737,7 +737,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryCacheMiss(String hql, String regionName) {
|
public void queryCacheMiss(String hql, String regionName) {
|
||||||
LOG.tracef( "Statistics#queryCacheMiss( `%s`, `%s` )", hql, regionName );
|
log.tracef( "Statistics#queryCacheMiss( `%s`, `%s` )", hql, regionName );
|
||||||
|
|
||||||
queryCacheMissCount.increment();
|
queryCacheMissCount.increment();
|
||||||
|
|
||||||
|
@ -750,7 +750,7 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void queryCachePut(String hql, String regionName) {
|
public void queryCachePut(String hql, String regionName) {
|
||||||
LOG.tracef( "Statistics#queryCachePut( `%s`, `%s` )", hql, regionName );
|
log.tracef( "Statistics#queryCachePut( `%s`, `%s` )", hql, regionName );
|
||||||
|
|
||||||
queryCachePutCount.increment();
|
queryCachePutCount.increment();
|
||||||
|
|
||||||
|
@ -890,45 +890,45 @@ public class StatisticsImpl implements StatisticsImplementor, Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logSummary() {
|
public void logSummary() {
|
||||||
LOG.loggingStatistics();
|
log.loggingStatistics();
|
||||||
LOG.startTime( startTime.toEpochMilli() );
|
log.startTime( startTime.toEpochMilli() );
|
||||||
LOG.sessionsOpened( sessionOpenCount.sum() );
|
log.sessionsOpened( sessionOpenCount.sum() );
|
||||||
LOG.sessionsClosed( sessionCloseCount.sum() );
|
log.sessionsClosed( sessionCloseCount.sum() );
|
||||||
LOG.transactions( transactionCount.sum() );
|
log.transactions( transactionCount.sum() );
|
||||||
LOG.successfulTransactions( committedTransactionCount.sum() );
|
log.successfulTransactions( committedTransactionCount.sum() );
|
||||||
LOG.optimisticLockFailures( optimisticFailureCount.sum() );
|
log.optimisticLockFailures( optimisticFailureCount.sum() );
|
||||||
LOG.flushes( flushCount.sum() );
|
log.flushes( flushCount.sum() );
|
||||||
LOG.connectionsObtained( connectCount.sum() );
|
log.connectionsObtained( connectCount.sum() );
|
||||||
LOG.statementsPrepared( prepareStatementCount.sum() );
|
log.statementsPrepared( prepareStatementCount.sum() );
|
||||||
LOG.statementsClosed( closeStatementCount.sum() );
|
log.statementsClosed( closeStatementCount.sum() );
|
||||||
LOG.secondLevelCachePuts( secondLevelCachePutCount.sum() );
|
log.secondLevelCachePuts( secondLevelCachePutCount.sum() );
|
||||||
LOG.secondLevelCacheHits( secondLevelCacheHitCount.sum() );
|
log.secondLevelCacheHits( secondLevelCacheHitCount.sum() );
|
||||||
LOG.secondLevelCacheMisses( secondLevelCacheMissCount.sum() );
|
log.secondLevelCacheMisses( secondLevelCacheMissCount.sum() );
|
||||||
LOG.entitiesLoaded( entityLoadCount.sum() );
|
log.entitiesLoaded( entityLoadCount.sum() );
|
||||||
LOG.entitiesUpdated( entityUpdateCount.sum() );
|
log.entitiesUpdated( entityUpdateCount.sum() );
|
||||||
LOG.entitiesInserted( entityInsertCount.sum() );
|
log.entitiesInserted( entityInsertCount.sum() );
|
||||||
LOG.entitiesDeleted( entityDeleteCount.sum() );
|
log.entitiesDeleted( entityDeleteCount.sum() );
|
||||||
LOG.entitiesFetched( entityFetchCount.sum() );
|
log.entitiesFetched( entityFetchCount.sum() );
|
||||||
LOG.collectionsLoaded( collectionLoadCount.sum() );
|
log.collectionsLoaded( collectionLoadCount.sum() );
|
||||||
LOG.collectionsUpdated( collectionUpdateCount.sum() );
|
log.collectionsUpdated( collectionUpdateCount.sum() );
|
||||||
LOG.collectionsRemoved( collectionRemoveCount.sum() );
|
log.collectionsRemoved( collectionRemoveCount.sum() );
|
||||||
LOG.collectionsRecreated( collectionRecreateCount.sum() );
|
log.collectionsRecreated( collectionRecreateCount.sum() );
|
||||||
LOG.collectionsFetched( collectionFetchCount.sum() );
|
log.collectionsFetched( collectionFetchCount.sum() );
|
||||||
LOG.naturalIdCachePuts( naturalIdCachePutCount.sum() );
|
log.naturalIdCachePuts( naturalIdCachePutCount.sum() );
|
||||||
LOG.naturalIdCacheHits( naturalIdCacheHitCount.sum() );
|
log.naturalIdCacheHits( naturalIdCacheHitCount.sum() );
|
||||||
LOG.naturalIdCacheMisses( naturalIdCacheMissCount.sum() );
|
log.naturalIdCacheMisses( naturalIdCacheMissCount.sum() );
|
||||||
LOG.naturalIdMaxQueryTime( naturalIdQueryExecutionMaxTime.get() );
|
log.naturalIdMaxQueryTime( naturalIdQueryExecutionMaxTime.get() );
|
||||||
LOG.naturalIdQueriesExecuted( naturalIdQueryExecutionCount.sum() );
|
log.naturalIdQueriesExecuted( naturalIdQueryExecutionCount.sum() );
|
||||||
LOG.queriesExecuted( queryExecutionCount.sum() );
|
log.queriesExecuted( queryExecutionCount.sum() );
|
||||||
LOG.queryCachePuts( queryCachePutCount.sum() );
|
log.queryCachePuts( queryCachePutCount.sum() );
|
||||||
LOG.timestampCachePuts( updateTimestampsCachePutCount.sum() );
|
log.timestampCachePuts( updateTimestampsCachePutCount.sum() );
|
||||||
LOG.timestampCacheHits( updateTimestampsCacheHitCount.sum() );
|
log.timestampCacheHits( updateTimestampsCacheHitCount.sum() );
|
||||||
LOG.timestampCacheMisses( updateTimestampsCacheMissCount.sum() );
|
log.timestampCacheMisses( updateTimestampsCacheMissCount.sum() );
|
||||||
LOG.queryCacheHits( queryCacheHitCount.sum() );
|
log.queryCacheHits( queryCacheHitCount.sum() );
|
||||||
LOG.queryCacheMisses( queryCacheMissCount.sum() );
|
log.queryCacheMisses( queryCacheMissCount.sum() );
|
||||||
LOG.maxQueryTime( queryExecutionMaxTime.get() );
|
log.maxQueryTime( queryExecutionMaxTime.get() );
|
||||||
LOG.queryPlanCacheHits( queryPlanCacheHitCount.sum() );
|
log.queryPlanCacheHits( queryPlanCacheHitCount.sum() );
|
||||||
LOG.queryPlanCacheMisses( queryPlanCacheMissCount.sum() );
|
log.queryPlanCacheMisses( queryPlanCacheMissCount.sum() );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -6,8 +6,7 @@ package org.hibernate.orm.test.annotations.collectionelement.recreate;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import org.hibernate.BaseSessionEventListener;
|
import org.hibernate.SessionEventListener;
|
||||||
|
|
||||||
import org.hibernate.testing.orm.junit.JiraKey;
|
import org.hibernate.testing.orm.junit.JiraKey;
|
||||||
import org.hibernate.testing.orm.junit.DomainModel;
|
import org.hibernate.testing.orm.junit.DomainModel;
|
||||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
import org.hibernate.testing.orm.junit.SessionFactory;
|
||||||
|
@ -29,7 +28,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
@SessionFactory
|
@SessionFactory
|
||||||
public class RecreateCollectionTest {
|
public class RecreateCollectionTest {
|
||||||
|
|
||||||
private static class StatementsCounterListener extends BaseSessionEventListener {
|
private static class StatementsCounterListener implements SessionEventListener {
|
||||||
int statements;
|
int statements;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.orm.test.event;
|
package org.hibernate.orm.test.event;
|
||||||
|
|
||||||
import org.hibernate.BaseSessionEventListener;
|
|
||||||
import org.hibernate.SessionEventListener;
|
import org.hibernate.SessionEventListener;
|
||||||
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
|
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class SessionEventListenersManagerTest extends BaseUnitTestCase {
|
||||||
Assert.assertEquals( "e", sb.toString() );
|
Assert.assertEquals( "e", sb.toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class TestSessionEventListener extends BaseSessionEventListener {
|
private static class TestSessionEventListener implements SessionEventListener {
|
||||||
|
|
||||||
private final StringBuilder sb;
|
private final StringBuilder sb;
|
||||||
private final char theChar;
|
private final char theChar;
|
||||||
|
|
Loading…
Reference in New Issue