HHH-8654 - Ability to get notified of interesting Session events
This commit is contained in:
parent
9e58a6de69
commit
1e74abf511
|
@ -24,13 +24,13 @@
|
|||
package org.hibernate;
|
||||
|
||||
/**
|
||||
* A no-op implementation of SessionEventsListener. Intended as a convenient base class for developing
|
||||
* SessionEventsListener implementations.
|
||||
* A no-op implementation of SessionEventListener. Intended as a convenient base class for developing
|
||||
* SessionEventListener implementations.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class EmptySessionEventsListener implements SessionEventsListener {
|
||||
public class BaseSessionEventListener implements SessionEventListener {
|
||||
@Override
|
||||
public void transactionCompletion(boolean successful) {
|
||||
}
|
|
@ -1104,5 +1104,5 @@ public interface Session extends SharedSessionContract {
|
|||
*
|
||||
* @param listeners The listener(s) to add
|
||||
*/
|
||||
public void addEventsListeners(SessionEventsListener... listeners);
|
||||
public void addEventListeners(SessionEventListener... listeners);
|
||||
}
|
||||
|
|
|
@ -119,13 +119,13 @@ public interface SessionBuilder {
|
|||
public SessionBuilder tenantIdentifier(String tenantIdentifier);
|
||||
|
||||
/**
|
||||
* Apply one or more SessionEventsListener instances to the listeners for the Session to be built.
|
||||
* Apply one or more SessionEventListener instances to the listeners for the Session to be built.
|
||||
*
|
||||
* @param listeners The listeners to incorporate into the built Session
|
||||
*
|
||||
* @return {@code this}, for method chaining
|
||||
*/
|
||||
public SessionBuilder eventListeners(SessionEventsListener... listeners);
|
||||
public SessionBuilder eventListeners(SessionEventListener... listeners);
|
||||
|
||||
/**
|
||||
* Remove all listeners intended for the built Session currently held here, including any auto-apply ones; in other
|
||||
|
|
|
@ -30,7 +30,7 @@ import java.io.Serializable;
|
|||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SessionEventsListener extends Serializable {
|
||||
public interface SessionEventListener extends Serializable {
|
||||
public void transactionCompletion(boolean successful);
|
||||
|
||||
public void jdbcConnectionAcquisitionStart();
|
|
@ -152,11 +152,11 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
|
||||
private boolean cacheInsert(EntityPersister persister, CacheKey ck) {
|
||||
try {
|
||||
getSession().getSessionEventsManager().cachePutStart();
|
||||
getSession().getEventListenerManager().cachePutStart();
|
||||
return persister.getCacheAccessStrategy().insert( ck, cacheEntry, version );
|
||||
}
|
||||
finally {
|
||||
getSession().getSessionEventsManager().cachePutEnd();
|
||||
getSession().getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
if ( success && isCachePutEnabled( persister, getSession() ) ) {
|
||||
final CacheKey ck = getSession().generateCacheKey( getId(), persister.getIdentifierType(), persister.getRootEntityName() );
|
||||
try {
|
||||
getSession().getSessionEventsManager().cachePutStart();
|
||||
getSession().getEventListenerManager().cachePutStart();
|
||||
final boolean put = persister.getCacheAccessStrategy().afterInsert( ck, cacheEntry, version );
|
||||
|
||||
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
|
@ -223,7 +223,7 @@ public final class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
getSession().getSessionEventsManager().cachePutEnd();
|
||||
getSession().getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
}
|
||||
postCommitInsert();
|
||||
|
|
|
@ -316,7 +316,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
|
||||
if ( success && cacheEntry!=null /*!persister.isCacheInvalidationRequired()*/ ) {
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
final boolean put = persister.getCacheAccessStrategy().afterUpdate( ck, cacheEntry, nextVersion, previousVersion, lock );
|
||||
|
||||
if ( put && getSession().getFactory().getStatistics().isStatisticsEnabled() ) {
|
||||
|
@ -324,7 +324,7 @@ public final class EntityUpdateAction extends EntityAction {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -144,11 +144,11 @@ public class StandardQueryCache implements QueryCache {
|
|||
}
|
||||
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
cacheRegion.put( key, cacheable );
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -233,11 +233,11 @@ public class StandardQueryCache implements QueryCache {
|
|||
private List getCachedResults(QueryKey key, SessionImplementor session) {
|
||||
List cacheable = null;
|
||||
try {
|
||||
session.getSessionEventsManager().cacheGetStart();
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
cacheable = (List) cacheRegion.get( key );
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cacheGetEnd( cacheable != null );
|
||||
session.getEventListenerManager().cacheGetEnd( cacheable != null );
|
||||
}
|
||||
return cacheable;
|
||||
}
|
||||
|
|
|
@ -104,14 +104,14 @@ public class UpdateTimestampsCache {
|
|||
}
|
||||
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
|
||||
//put() has nowait semantics, is this really appropriate?
|
||||
//note that it needs to be async replication, never local or sync
|
||||
region.put( space, ts );
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
||||
if ( stats ) {
|
||||
|
@ -140,14 +140,14 @@ public class UpdateTimestampsCache {
|
|||
}
|
||||
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
|
||||
//put() has nowait semantics, is this really appropriate?
|
||||
//note that it needs to be async replication, never local or sync
|
||||
region.put( space, ts );
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
||||
if ( stats ) {
|
||||
|
@ -204,11 +204,11 @@ public class UpdateTimestampsCache {
|
|||
private Long getLastUpdateTimestampForSpace(Serializable space, SessionImplementor session) {
|
||||
Long ts = null;
|
||||
try {
|
||||
session.getSessionEventsManager().cacheGetStart();
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
ts = (Long) region.get( space );
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cacheGetEnd( ts != null );
|
||||
session.getEventListenerManager().cacheGetEnd( ts != null );
|
||||
}
|
||||
return ts;
|
||||
}
|
||||
|
|
|
@ -670,7 +670,7 @@ public interface AvailableSettings {
|
|||
String UNIQUE_CONSTRAINT_SCHEMA_UPDATE_STRATEGY = "hibernate.schema_update.unique_constraint_strategy";
|
||||
|
||||
/**
|
||||
* A setting to control whether to {@link org.hibernate.engine.internal.LoggingSessionEventsListener} is
|
||||
* A setting to control whether to {@link org.hibernate.engine.internal.StatisticalLoggingSessionEventListener} is
|
||||
* enabled on all Sessions (unless explicitly disabled for a given Session). The default value of this
|
||||
* setting is determined by the value for {@link #GENERATE_STATISTICS}, meaning that if collection of statistics
|
||||
* is enabled logging of Session metrics is enabled by default too.
|
||||
|
|
|
@ -27,19 +27,19 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.engine.internal.LoggingSessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.engine.internal.StatisticalLoggingSessionEventListener;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class BaselineSessionEventsListenerBuilder {
|
||||
private boolean logSessionMetrics;
|
||||
private Class<? extends SessionEventsListener> autoListener;
|
||||
private Class<? extends SessionEventListener> autoListener;
|
||||
|
||||
public BaselineSessionEventsListenerBuilder(
|
||||
boolean logSessionMetrics,
|
||||
Class<? extends SessionEventsListener> autoListener) {
|
||||
Class<? extends SessionEventListener> autoListener) {
|
||||
this.logSessionMetrics = logSessionMetrics;
|
||||
this.autoListener = autoListener;
|
||||
}
|
||||
|
@ -55,19 +55,19 @@ public class BaselineSessionEventsListenerBuilder {
|
|||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public Class<? extends SessionEventsListener> getAutoListener() {
|
||||
public Class<? extends SessionEventListener> getAutoListener() {
|
||||
return autoListener;
|
||||
}
|
||||
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public void setAutoListener(Class<? extends SessionEventsListener> autoListener) {
|
||||
public void setAutoListener(Class<? extends SessionEventListener> autoListener) {
|
||||
this.autoListener = autoListener;
|
||||
}
|
||||
|
||||
public List<SessionEventsListener> buildBaselineList() {
|
||||
List<SessionEventsListener> list = new ArrayList<SessionEventsListener>();
|
||||
if ( logSessionMetrics && LoggingSessionEventsListener.isLoggingEnabled() ) {
|
||||
list.add( new LoggingSessionEventsListener() );
|
||||
public List<SessionEventListener> buildBaselineList() {
|
||||
List<SessionEventListener> list = new ArrayList<SessionEventListener>();
|
||||
if ( logSessionMetrics && StatisticalLoggingSessionEventListener.isLoggingEnabled() ) {
|
||||
list.add( new StatisticalLoggingSessionEventListener() );
|
||||
}
|
||||
if ( autoListener != null ) {
|
||||
try {
|
||||
|
@ -75,7 +75,7 @@ public class BaselineSessionEventsListenerBuilder {
|
|||
}
|
||||
catch (Exception e) {
|
||||
throw new HibernateException(
|
||||
"Unable to instantiate specified auto SessionEventsListener : " + autoListener.getName(),
|
||||
"Unable to instantiate specified auto SessionEventListener : " + autoListener.getName(),
|
||||
e
|
||||
);
|
||||
}
|
||||
|
|
|
@ -34,14 +34,13 @@ import org.hibernate.EntityMode;
|
|||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MultiTenancyStrategy;
|
||||
import org.hibernate.NullPrecedence;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.cache.internal.NoCachingRegionFactory;
|
||||
import org.hibernate.cache.internal.RegionFactoryInitiator;
|
||||
import org.hibernate.cache.internal.StandardQueryCacheFactory;
|
||||
import org.hibernate.cache.spi.QueryCacheFactory;
|
||||
import org.hibernate.cache.spi.RegionFactory;
|
||||
import org.hibernate.engine.internal.LoggingSessionEventsListener;
|
||||
import org.hibernate.engine.jdbc.spi.ExtractedDatabaseMetaData;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.transaction.spi.TransactionFactory;
|
||||
|
@ -416,9 +415,9 @@ public class SettingsFactory implements Serializable {
|
|||
settings.setJtaTrackByThread( jtaTrackByThread );
|
||||
|
||||
final String autoSessionEventsListenerName = properties.getProperty( AvailableSettings.AUTO_SESSION_EVENTS_LISTENER );
|
||||
final Class<? extends SessionEventsListener> autoSessionEventsListener = autoSessionEventsListenerName == null
|
||||
final Class<? extends SessionEventListener> autoSessionEventsListener = autoSessionEventsListenerName == null
|
||||
? null
|
||||
: strategySelector.selectStrategyImplementor( SessionEventsListener.class, autoSessionEventsListenerName );
|
||||
: strategySelector.selectStrategyImplementor( SessionEventListener.class, autoSessionEventsListenerName );
|
||||
|
||||
final boolean logSessionMetrics = ConfigurationHelper.getBoolean(
|
||||
AvailableSettings.LOG_SESSION_METRICS,
|
||||
|
|
|
@ -27,18 +27,18 @@ import java.io.Serializable;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class SessionEventsManagerImpl implements SessionEventsManager, Serializable {
|
||||
private List<SessionEventsListener> listenerList;
|
||||
public class SessionEventListenerManagerImpl implements SessionEventListenerManager, Serializable {
|
||||
private List<SessionEventListener> listenerList;
|
||||
|
||||
public void addListener(SessionEventsListener... listeners) {
|
||||
public void addListener(SessionEventListener... listeners) {
|
||||
if ( listenerList == null ) {
|
||||
listenerList = new ArrayList<SessionEventsListener>();
|
||||
listenerList = new ArrayList<SessionEventListener>();
|
||||
}
|
||||
|
||||
java.util.Collections.addAll( listenerList, listeners );
|
||||
|
@ -50,7 +50,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.transactionCompletion( successful );
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcConnectionAcquisitionStart();
|
||||
}
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcConnectionAcquisitionEnd();
|
||||
}
|
||||
}
|
||||
|
@ -83,7 +83,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcConnectionReleaseStart();
|
||||
}
|
||||
}
|
||||
|
@ -94,7 +94,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcConnectionReleaseEnd();
|
||||
}
|
||||
}
|
||||
|
@ -105,7 +105,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcPrepareStatementStart();
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcPrepareStatementEnd();
|
||||
}
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcExecuteStatementStart();
|
||||
}
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcExecuteStatementEnd();
|
||||
}
|
||||
}
|
||||
|
@ -149,7 +149,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcExecuteBatchStart();
|
||||
}
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.jdbcExecuteBatchEnd();
|
||||
}
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.cachePutStart();
|
||||
}
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.cachePutEnd();
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.cacheGetStart();
|
||||
}
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.cacheGetEnd( hit );
|
||||
}
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.flushStart();
|
||||
}
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.flushEnd( numberOfEntities, numberOfCollections );
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.partialFlushStart();
|
||||
}
|
||||
}
|
||||
|
@ -248,7 +248,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.partialFlushEnd( numberOfEntities, numberOfCollections );
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.dirtyCalculationStart();
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.dirtyCalculationEnd( dirty );
|
||||
}
|
||||
}
|
||||
|
@ -281,7 +281,7 @@ public class SessionEventsManagerImpl implements SessionEventsManager, Serializa
|
|||
return;
|
||||
}
|
||||
|
||||
for ( SessionEventsListener listener : listenerList ) {
|
||||
for ( SessionEventListener listener : listenerList ) {
|
||||
listener.end();
|
||||
}
|
||||
}
|
|
@ -25,13 +25,13 @@ package org.hibernate.engine.internal;
|
|||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.EmptySessionEventsListener;
|
||||
import org.hibernate.BaseSessionEventListener;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class LoggingSessionEventsListener extends EmptySessionEventsListener {
|
||||
private static final Logger log = Logger.getLogger( LoggingSessionEventsListener.class );
|
||||
public class StatisticalLoggingSessionEventListener extends BaseSessionEventListener {
|
||||
private static final Logger log = Logger.getLogger( StatisticalLoggingSessionEventListener.class );
|
||||
|
||||
/**
|
||||
* Used by SettingsFactory (in conjunction with stats being enabled) to determine whether to apply this listener
|
|
@ -217,7 +217,7 @@ public final class TwoPhaseLoad {
|
|||
}
|
||||
else {
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
final boolean put = persister.getCacheAccessStrategy().putFromLoad(
|
||||
cacheKey,
|
||||
persister.getCacheEntryStructure().structure( entry ),
|
||||
|
@ -231,7 +231,7 @@ public final class TwoPhaseLoad {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -350,7 +350,7 @@ public class CollectionLoadContext {
|
|||
final CacheKey cacheKey = session.generateCacheKey( lce.getKey(), persister.getKeyType(), persister.getRole() );
|
||||
|
||||
try {
|
||||
session.getSessionEventsManager().cachePutStart();
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
final boolean put = persister.getCacheAccessStrategy().putFromLoad(
|
||||
cacheKey,
|
||||
persister.getCacheEntryStructure().structure( entry ),
|
||||
|
@ -364,7 +364,7 @@ public class CollectionLoadContext {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().cachePutEnd();
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.hibernate.SQLQuery;
|
|||
import org.hibernate.ScrollMode;
|
||||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.SharedSessionBuilder;
|
||||
import org.hibernate.SimpleNaturalIdLoadAccess;
|
||||
|
@ -390,8 +390,8 @@ public class SessionDelegatorBaseImpl implements SessionImplementor, Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public SessionEventsManager getSessionEventsManager() {
|
||||
return sessionImplementor.getSessionEventsManager();
|
||||
public SessionEventListenerManager getEventListenerManager() {
|
||||
return sessionImplementor.getEventListenerManager();
|
||||
}
|
||||
|
||||
// Delegates to Session
|
||||
|
@ -807,7 +807,7 @@ public class SessionDelegatorBaseImpl implements SessionImplementor, Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addEventsListeners(SessionEventsListener... listeners) {
|
||||
session.addEventsListeners( listeners );
|
||||
public void addEventListeners(SessionEventListener... listeners) {
|
||||
session.addEventListeners( listeners );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
*/
|
||||
package org.hibernate.engine.spi;
|
||||
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface SessionEventsManager extends SessionEventsListener {
|
||||
public interface SessionEventListenerManager extends SessionEventListener {
|
||||
}
|
|
@ -408,5 +408,5 @@ public interface SessionImplementor extends Serializable, LobCreationContext {
|
|||
*/
|
||||
SQLQuery createSQLQuery(NamedSQLQueryDefinition namedQueryDefinition);
|
||||
|
||||
public SessionEventsManager getSessionEventsManager();
|
||||
public SessionEventListenerManager getEventListenerManager();
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
|
||||
final EventSource source = event.getSession();
|
||||
try {
|
||||
source.getSessionEventsManager().partialFlushStart();
|
||||
source.getEventListenerManager().partialFlushStart();
|
||||
|
||||
if ( flushMightBeNeeded(source) ) {
|
||||
// Need to get the number of collection removals before flushing to executions
|
||||
|
@ -82,7 +82,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
}
|
||||
}
|
||||
finally {
|
||||
source.getSessionEventsManager().partialFlushEnd(
|
||||
source.getEventListenerManager().partialFlushEnd(
|
||||
event.getNumberOfEntitiesProcessed(),
|
||||
event.getNumberOfEntitiesProcessed()
|
||||
);
|
||||
|
|
|
@ -527,7 +527,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
|
|||
if ( dirtyProperties==null ) {
|
||||
// Interceptor returned null, so do the dirtycheck ourself, if possible
|
||||
try {
|
||||
session.getSessionEventsManager().dirtyCalculationStart();
|
||||
session.getEventListenerManager().dirtyCalculationStart();
|
||||
|
||||
interceptorHandledDirtyCheck = false;
|
||||
// object loaded by update()
|
||||
|
@ -567,7 +567,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
|
|||
}
|
||||
}
|
||||
finally {
|
||||
session.getSessionEventsManager().dirtyCalculationEnd( dirtyProperties != null );
|
||||
session.getEventListenerManager().dirtyCalculationEnd( dirtyProperties != null );
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -50,14 +50,14 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
|
|||
persistenceContext.getCollectionEntries().size() > 0 ) {
|
||||
|
||||
try {
|
||||
source.getSessionEventsManager().flushStart();
|
||||
source.getEventListenerManager().flushStart();
|
||||
|
||||
flushEverythingToExecutions( event );
|
||||
performExecutions( source );
|
||||
postFlush( source );
|
||||
}
|
||||
finally {
|
||||
source.getSessionEventsManager().flushEnd(
|
||||
source.getEventListenerManager().flushEnd(
|
||||
event.getNumberOfEntitiesProcessed(),
|
||||
event.getNumberOfCollectionsProcessed()
|
||||
);
|
||||
|
|
|
@ -128,7 +128,7 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
|
|||
|
||||
Object ce = null;
|
||||
try {
|
||||
source.getSessionEventsManager().cacheGetStart();
|
||||
source.getEventListenerManager().cacheGetStart();
|
||||
ce = persister.getCacheAccessStrategy().get(ck, source.getTimestamp());
|
||||
|
||||
if ( factory.getStatistics().isStatisticsEnabled() ) {
|
||||
|
@ -143,7 +143,7 @@ public class DefaultInitializeCollectionEventListener implements InitializeColle
|
|||
}
|
||||
}
|
||||
finally {
|
||||
source.getSessionEventsManager().cacheGetEnd( ce == null );
|
||||
source.getEventListenerManager().cacheGetEnd( ce == null );
|
||||
}
|
||||
|
||||
if ( ce == null ) {
|
||||
|
|
|
@ -549,7 +549,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
|||
|
||||
Object ce = null;
|
||||
try {
|
||||
source.getSessionEventsManager().cacheGetStart();
|
||||
source.getEventListenerManager().cacheGetStart();
|
||||
ce = persister.getCacheAccessStrategy().get( ck, source.getTimestamp() );
|
||||
|
||||
if ( factory.getStatistics().isStatisticsEnabled() ) {
|
||||
|
@ -566,7 +566,7 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
|||
}
|
||||
}
|
||||
finally {
|
||||
source.getSessionEventsManager().cacheGetEnd( ce == null );
|
||||
source.getEventListenerManager().cacheGetEnd( ce == null );
|
||||
}
|
||||
|
||||
if ( ce == null ) {
|
||||
|
|
|
@ -41,7 +41,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.engine.jdbc.internal.FormatStyle;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.id.enhanced.AccessCallback;
|
||||
import org.hibernate.id.enhanced.LegacyHiLoAlgorithmOptimizer;
|
||||
|
@ -146,7 +146,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
|
|||
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getSqlStatementLogger();
|
||||
final SessionEventsManager statsCollector = session.getSessionEventsManager();
|
||||
final SessionEventListenerManager statsCollector = session.getEventListenerManager();
|
||||
|
||||
final WorkExecutorVisitable<IntegralDataTypeHolder> work = new AbstractReturningWork<IntegralDataTypeHolder>() {
|
||||
@Override
|
||||
|
@ -235,7 +235,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger statementLogger,
|
||||
SessionEventsManager statsCollector) throws SQLException {
|
||||
SessionEventListenerManager statsCollector) throws SQLException {
|
||||
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
try {
|
||||
statsCollector.jdbcPrepareStatementStart();
|
||||
|
@ -246,7 +246,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
|
|||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
|
@ -257,7 +257,7 @@ public class MultipleHiLoPerTableGenerator implements PersistentIdentifierGenera
|
|||
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
|
|
|
@ -40,7 +40,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.engine.jdbc.internal.FormatStyle;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.id.enhanced.SequenceStyleGenerator;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
@ -148,7 +148,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getSqlStatementLogger();
|
||||
final SessionEventsManager statsCollector = session.getSessionEventsManager();
|
||||
final SessionEventListenerManager listeners = session.getEventListenerManager();
|
||||
|
||||
return session.getTransactionCoordinator().getTransaction().createIsolationDelegate().delegateWork(
|
||||
new AbstractReturningWork<IntegralDataTypeHolder>() {
|
||||
|
@ -160,9 +160,9 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
// The loop ensures atomicity of the select + update even for no transaction or
|
||||
// read committed isolation level
|
||||
do {
|
||||
final PreparedStatement qps = prepareStatement( connection, query, statementLogger, statsCollector );
|
||||
final PreparedStatement qps = prepareStatement( connection, query, statementLogger, listeners );
|
||||
try {
|
||||
ResultSet rs = executeQuery( qps, statsCollector );
|
||||
ResultSet rs = executeQuery( qps, listeners );
|
||||
if ( !rs.next() ) {
|
||||
String err = "could not read a hi value - you need to populate the table: " + tableName;
|
||||
LOG.error(err);
|
||||
|
@ -179,11 +179,11 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
qps.close();
|
||||
}
|
||||
|
||||
final PreparedStatement ups = prepareStatement( connection, update, statementLogger, statsCollector );
|
||||
final PreparedStatement ups = prepareStatement( connection, update, statementLogger, listeners );
|
||||
try {
|
||||
value.copy().increment().bind( ups, 1 );
|
||||
value.bind( ups, 2 );
|
||||
rows = executeUpdate( ups, statsCollector );
|
||||
rows = executeUpdate( ups, listeners );
|
||||
}
|
||||
catch (SQLException sqle) {
|
||||
LOG.error(LOG.unableToUpdateHiValue(tableName), sqle);
|
||||
|
@ -205,7 +205,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger statementLogger,
|
||||
SessionEventsManager statsCollector) throws SQLException {
|
||||
SessionEventListenerManager statsCollector) throws SQLException {
|
||||
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
try {
|
||||
statsCollector.jdbcPrepareStatementStart();
|
||||
|
@ -216,7 +216,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
|
@ -227,7 +227,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
|
|
|
@ -45,7 +45,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.engine.jdbc.internal.FormatStyle;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.id.Configurable;
|
||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||
|
@ -529,7 +529,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getSqlStatementLogger();
|
||||
final SessionEventsManager statsCollector = session.getSessionEventsManager();
|
||||
final SessionEventListenerManager statsCollector = session.getEventListenerManager();
|
||||
|
||||
return optimizer.generate(
|
||||
new AccessCallback() {
|
||||
|
@ -619,7 +619,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger statementLogger,
|
||||
SessionEventsManager statsCollector) throws SQLException {
|
||||
SessionEventListenerManager statsCollector) throws SQLException {
|
||||
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
try {
|
||||
statsCollector.jdbcPrepareStatementStart();
|
||||
|
@ -630,7 +630,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
|
@ -641,7 +641,7 @@ public class TableGenerator implements PersistentIdentifierGenerator, Configurab
|
|||
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
|
|
|
@ -37,7 +37,7 @@ import org.hibernate.dialect.Dialect;
|
|||
import org.hibernate.engine.jdbc.internal.FormatStyle;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.id.IdentifierGenerationException;
|
||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||
|
@ -123,7 +123,7 @@ public class TableStructure implements DatabaseStructure {
|
|||
final SqlStatementLogger statementLogger = session.getFactory().getServiceRegistry()
|
||||
.getService( JdbcServices.class )
|
||||
.getSqlStatementLogger();
|
||||
final SessionEventsManager statsCollector = session.getSessionEventsManager();
|
||||
final SessionEventListenerManager statsCollector = session.getEventListenerManager();
|
||||
|
||||
return new AccessCallback() {
|
||||
@Override
|
||||
|
@ -192,7 +192,7 @@ public class TableStructure implements DatabaseStructure {
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger statementLogger,
|
||||
SessionEventsManager statsCollector) throws SQLException {
|
||||
SessionEventListenerManager statsCollector) throws SQLException {
|
||||
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
try {
|
||||
statsCollector.jdbcPrepareStatementStart();
|
||||
|
@ -203,7 +203,7 @@ public class TableStructure implements DatabaseStructure {
|
|||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
|
@ -214,7 +214,7 @@ public class TableStructure implements DatabaseStructure {
|
|||
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventsManager statsCollector) throws SQLException {
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector) throws SQLException {
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
|
|
|
@ -35,10 +35,9 @@ import org.hibernate.MultiTenancyStrategy;
|
|||
import org.hibernate.Query;
|
||||
import org.hibernate.SQLQuery;
|
||||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.SessionException;
|
||||
import org.hibernate.SharedSessionContract;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.procedure.ProcedureCall;
|
||||
import org.hibernate.cache.spi.CacheKey;
|
||||
import org.hibernate.engine.jdbc.LobCreationContext;
|
||||
|
@ -340,13 +339,13 @@ public abstract class AbstractSessionImpl
|
|||
if ( jdbcConnectionAccess == null ) {
|
||||
if ( MultiTenancyStrategy.NONE == factory.getSettings().getMultiTenancyStrategy() ) {
|
||||
jdbcConnectionAccess = new NonContextualJdbcConnectionAccess(
|
||||
getSessionEventsManager(),
|
||||
getEventListenerManager(),
|
||||
factory.getServiceRegistry().getService( ConnectionProvider.class )
|
||||
);
|
||||
}
|
||||
else {
|
||||
jdbcConnectionAccess = new ContextualJdbcConnectionAccess(
|
||||
getSessionEventsManager(),
|
||||
getEventListenerManager(),
|
||||
factory.getServiceRegistry().getService( MultiTenantConnectionProvider.class )
|
||||
);
|
||||
}
|
||||
|
@ -364,11 +363,11 @@ public abstract class AbstractSessionImpl
|
|||
}
|
||||
|
||||
private static class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
|
||||
private final SessionEventsListener listener;
|
||||
private final SessionEventListener listener;
|
||||
private final ConnectionProvider connectionProvider;
|
||||
|
||||
private NonContextualJdbcConnectionAccess(
|
||||
SessionEventsListener listener,
|
||||
SessionEventListener listener,
|
||||
ConnectionProvider connectionProvider) {
|
||||
this.listener = listener;
|
||||
this.connectionProvider = connectionProvider;
|
||||
|
@ -403,11 +402,11 @@ public abstract class AbstractSessionImpl
|
|||
}
|
||||
|
||||
private class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Serializable {
|
||||
private final SessionEventsListener listener;
|
||||
private final SessionEventListener listener;
|
||||
private final MultiTenantConnectionProvider connectionProvider;
|
||||
|
||||
private ContextualJdbcConnectionAccess(
|
||||
SessionEventsListener listener,
|
||||
SessionEventListener listener,
|
||||
MultiTenantConnectionProvider connectionProvider) {
|
||||
this.listener = listener;
|
||||
this.connectionProvider = connectionProvider;
|
||||
|
|
|
@ -57,7 +57,7 @@ import org.hibernate.MultiTenancyStrategy;
|
|||
import org.hibernate.ObjectNotFoundException;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionBuilder;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.SessionFactoryObserver;
|
||||
import org.hibernate.StatelessSession;
|
||||
|
@ -1553,7 +1553,7 @@ public final class SessionFactoryImpl
|
|||
private boolean autoJoinTransactions = true;
|
||||
private boolean flushBeforeCompletion;
|
||||
private String tenantIdentifier;
|
||||
private List<SessionEventsListener> listeners;
|
||||
private List<SessionEventListener> listeners;
|
||||
|
||||
SessionBuilderImpl(SessionFactoryImpl sessionFactory) {
|
||||
this.sessionFactory = sessionFactory;
|
||||
|
@ -1594,8 +1594,8 @@ public final class SessionFactoryImpl
|
|||
tenantIdentifier
|
||||
);
|
||||
|
||||
for ( SessionEventsListener listener : listeners ) {
|
||||
session.getSessionEventsManager().addListener( listener );
|
||||
for ( SessionEventListener listener : listeners ) {
|
||||
session.getEventListenerManager().addListener( listener );
|
||||
}
|
||||
|
||||
return session;
|
||||
|
@ -1656,7 +1656,7 @@ public final class SessionFactoryImpl
|
|||
}
|
||||
|
||||
@Override
|
||||
public SessionBuilder eventListeners(SessionEventsListener... listeners) {
|
||||
public SessionBuilder eventListeners(SessionEventListener... listeners) {
|
||||
Collections.addAll( this.listeners, listeners );
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ import org.hibernate.ScrollMode;
|
|||
import org.hibernate.ScrollableResults;
|
||||
import org.hibernate.Session;
|
||||
import org.hibernate.SessionBuilder;
|
||||
import org.hibernate.SessionEventsListener;
|
||||
import org.hibernate.SessionEventListener;
|
||||
import org.hibernate.SessionException;
|
||||
import org.hibernate.SharedSessionBuilder;
|
||||
import org.hibernate.SimpleNaturalIdLoadAccess;
|
||||
|
@ -84,7 +84,7 @@ import org.hibernate.UnknownProfileException;
|
|||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.criterion.NaturalIdentifier;
|
||||
import org.hibernate.engine.internal.SessionEventsManagerImpl;
|
||||
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
|
||||
import org.hibernate.engine.internal.StatefulPersistenceContext;
|
||||
import org.hibernate.engine.jdbc.LobCreator;
|
||||
import org.hibernate.engine.jdbc.NonContextualLobCreator;
|
||||
|
@ -213,6 +213,8 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
|
|||
private final transient boolean isTransactionCoordinatorShared;
|
||||
private transient TransactionObserver transactionObserver;
|
||||
|
||||
private SessionEventListenerManagerImpl sessionEventsManager = new SessionEventListenerManagerImpl();
|
||||
|
||||
/**
|
||||
* Constructor used for openSession(...) processing, as well as construction
|
||||
* of sessions for getCurrentSession().
|
||||
|
@ -357,7 +359,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
|
|||
if ( factory.getStatistics().isStatisticsEnabled() ) {
|
||||
factory.getStatisticsImplementor().closeSession();
|
||||
}
|
||||
getSessionEventsManager().end();
|
||||
getEventListenerManager().end();
|
||||
|
||||
try {
|
||||
if ( !isTransactionCoordinatorShared ) {
|
||||
|
@ -635,7 +637,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
|
|||
persistenceContext.afterTransactionCompletion();
|
||||
actionQueue.afterTransactionCompletion( successful );
|
||||
|
||||
getSessionEventsManager().transactionCompletion( successful );
|
||||
getEventListenerManager().transactionCompletion( successful );
|
||||
|
||||
try {
|
||||
interceptor.afterTransactionCompletion( hibernateTransaction );
|
||||
|
@ -659,50 +661,44 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
|
|||
return sql;
|
||||
}
|
||||
|
||||
private SessionEventsManagerImpl sessionEventsManager;
|
||||
|
||||
@Override
|
||||
public SessionEventsManagerImpl getSessionEventsManager() {
|
||||
if ( sessionEventsManager == null ) {
|
||||
sessionEventsManager = new SessionEventsManagerImpl();
|
||||
}
|
||||
|
||||
public SessionEventListenerManagerImpl getEventListenerManager() {
|
||||
return sessionEventsManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEventsListeners(SessionEventsListener... listeners) {
|
||||
getSessionEventsManager().addListener( listeners );
|
||||
public void addEventListeners(SessionEventListener... listeners) {
|
||||
getEventListenerManager().addListener( listeners );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startPrepareStatement() {
|
||||
getSessionEventsManager().jdbcPrepareStatementStart();
|
||||
getEventListenerManager().jdbcPrepareStatementStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endPrepareStatement() {
|
||||
getSessionEventsManager().jdbcPrepareStatementEnd();
|
||||
getEventListenerManager().jdbcPrepareStatementEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startStatementExecution() {
|
||||
getSessionEventsManager().jdbcExecuteStatementStart();
|
||||
getEventListenerManager().jdbcExecuteStatementStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endStatementExecution() {
|
||||
getSessionEventsManager().jdbcExecuteStatementEnd();
|
||||
getEventListenerManager().jdbcExecuteStatementEnd();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startBatchExecution() {
|
||||
getSessionEventsManager().jdbcExecuteBatchStart();
|
||||
getEventListenerManager().jdbcExecuteBatchStart();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void endBatchExecution() {
|
||||
getSessionEventsManager().jdbcExecuteBatchEnd();
|
||||
getEventListenerManager().jdbcExecuteBatchEnd();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2442,7 +2438,7 @@ public final class SessionImpl extends AbstractSessionImpl implements EventSourc
|
|||
}
|
||||
|
||||
@Override
|
||||
public SharedSessionBuilder eventListeners(SessionEventsListener... listeners) {
|
||||
public SharedSessionBuilder eventListeners(SessionEventListener... listeners) {
|
||||
super.eventListeners( listeners );
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ import org.hibernate.Transaction;
|
|||
import org.hibernate.UnresolvableObjectException;
|
||||
import org.hibernate.cache.spi.CacheKey;
|
||||
import org.hibernate.collection.spi.PersistentCollection;
|
||||
import org.hibernate.engine.internal.SessionEventsManagerImpl;
|
||||
import org.hibernate.engine.internal.SessionEventListenerManagerImpl;
|
||||
import org.hibernate.engine.internal.StatefulPersistenceContext;
|
||||
import org.hibernate.engine.internal.Versioning;
|
||||
import org.hibernate.engine.query.spi.HQLQueryPlan;
|
||||
|
@ -59,7 +59,7 @@ import org.hibernate.engine.spi.LoadQueryInfluencers;
|
|||
import org.hibernate.engine.spi.NonFlushedChanges;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.QueryParameters;
|
||||
import org.hibernate.engine.spi.SessionEventsManager;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.transaction.internal.TransactionCoordinatorImpl;
|
||||
import org.hibernate.engine.transaction.spi.TransactionCoordinator;
|
||||
import org.hibernate.engine.transaction.spi.TransactionEnvironment;
|
||||
|
@ -395,12 +395,12 @@ public class StatelessSessionImpl extends AbstractSessionImpl implements Statele
|
|||
return sql;
|
||||
}
|
||||
|
||||
private SessionEventsManagerImpl sessionEventsManager;
|
||||
private SessionEventListenerManagerImpl sessionEventsManager;
|
||||
|
||||
@Override
|
||||
public SessionEventsManager getSessionEventsManager() {
|
||||
public SessionEventListenerManager getEventListenerManager() {
|
||||
if ( sessionEventsManager == null ) {
|
||||
sessionEventsManager = new SessionEventsManagerImpl();
|
||||
sessionEventsManager = new SessionEventListenerManagerImpl();
|
||||
}
|
||||
return sessionEventsManager;
|
||||
}
|
||||
|
|
|
@ -56,4 +56,4 @@ log4j.logger.org.hibernate.loader.plan2.build.internal.LoadPlanImpl=debug
|
|||
log4j.logger.org.hibernate.loader.plan2.build.spi.LoadPlanTreePrinter=debug
|
||||
log4j.logger.org.hibernate.loader.plan2.exec.spi.EntityLoadQueryDetails=debug
|
||||
|
||||
log4j.logger.org.hibernate.engine.internal.LoggingSessionEventsListener=info
|
||||
log4j.logger.org.hibernate.engine.internal.StatisticalLoggingSessionEventListener=info
|
Loading…
Reference in New Issue