HHH-17347 Support for JDK which do not support JFR events
This commit is contained in:
parent
5b6373fb34
commit
16eecea9d0
|
@ -89,8 +89,6 @@ dependencies {
|
|||
|
||||
testImplementation testLibs.byteman
|
||||
|
||||
testImplementation testLibs.jfrUnit
|
||||
|
||||
testRuntimeOnly testLibs.log4j2
|
||||
testRuntimeOnly libs.byteBuddy
|
||||
|
||||
|
|
|
@ -17,9 +17,8 @@ import org.hibernate.engine.spi.PersistenceContext;
|
|||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager.CacheActionDescription;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.PostCommitInsertEventListener;
|
||||
|
@ -164,7 +163,8 @@ public class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
|
||||
protected boolean cacheInsert(EntityPersister persister, Object ck) {
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
final EntityDataAccess cacheAccessStrategy = persister.getCacheAccessStrategy();
|
||||
boolean insert = false;
|
||||
try {
|
||||
|
@ -173,13 +173,13 @@ public class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
return insert;
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheAccessStrategy,
|
||||
getPersister(),
|
||||
insert,
|
||||
CacheActionDescription.ENTITY_INSERT
|
||||
EventManager.CacheActionDescription.ENTITY_INSERT
|
||||
);
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
@ -255,7 +255,8 @@ public class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
protected boolean cacheAfterInsert(EntityDataAccess cache, Object ck) {
|
||||
SharedSessionContractImplementor session = getSession();
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
boolean afterInsert = false;
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
|
@ -263,13 +264,13 @@ public class EntityInsertAction extends AbstractEntityInsertAction {
|
|||
return afterInsert;
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cache,
|
||||
getPersister(),
|
||||
afterInsert,
|
||||
CacheActionDescription.ENTITY_AFTER_INSERT
|
||||
EventManager.CacheActionDescription.ENTITY_AFTER_INSERT
|
||||
);
|
||||
eventListenerManager.cachePutEnd();
|
||||
}
|
||||
|
|
|
@ -19,8 +19,8 @@ import org.hibernate.engine.spi.SessionEventListenerManager;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.PostCommitUpdateEventListener;
|
||||
|
@ -309,7 +309,8 @@ public class EntityUpdateAction extends EntityAction {
|
|||
|
||||
protected boolean updateCache(EntityPersister persister, Object previousVersion, Object ck) {
|
||||
final SharedSessionContractImplementor session = getSession();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
final EntityDataAccess cacheAccessStrategy = persister.getCacheAccessStrategy();
|
||||
boolean update = false;
|
||||
try {
|
||||
|
@ -318,13 +319,13 @@ public class EntityUpdateAction extends EntityAction {
|
|||
return update;
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheAccessStrategy,
|
||||
getPersister(),
|
||||
update,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
EventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
);
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
@ -434,20 +435,21 @@ public class EntityUpdateAction extends EntityAction {
|
|||
|
||||
protected void cacheAfterUpdate(EntityDataAccess cache, Object ck, SharedSessionContractImplementor session) {
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
boolean put = false;
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
put = cache.afterUpdate( session, ck, cacheEntry, nextVersion, previousVersion, lock );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cache,
|
||||
getPersister(),
|
||||
put,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_AFTER_UPDATE
|
||||
EventManager.CacheActionDescription.ENTITY_AFTER_UPDATE
|
||||
);
|
||||
final StatisticsImplementor statistics = session.getFactory().getStatistics();
|
||||
if ( put && statistics.isStatisticsEnabled() ) {
|
||||
|
|
|
@ -17,9 +17,8 @@ import org.hibernate.cache.spi.QueryResultsCache;
|
|||
import org.hibernate.cache.spi.QueryResultsRegion;
|
||||
import org.hibernate.cache.spi.TimestampsCache;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
|
||||
import static org.hibernate.cache.spi.SecondLevelCacheLogger.L2CACHE_LOGGER;
|
||||
|
||||
|
@ -64,18 +63,19 @@ public class QueryResultsCacheImpl implements QueryResultsCache {
|
|||
deepCopy( results )
|
||||
);
|
||||
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
session.getEventListenerManager().cachePutStart();
|
||||
cacheRegion.putIntoCache( key, cacheItem, session );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheRegion,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.QUERY_RESULT
|
||||
EventManager.CacheActionDescription.QUERY_RESULT
|
||||
);
|
||||
session.getEventListenerManager().cachePutEnd();
|
||||
}
|
||||
|
@ -153,13 +153,14 @@ public class QueryResultsCacheImpl implements QueryResultsCache {
|
|||
|
||||
private CacheItem getCachedData(QueryKey key, SharedSessionContractImplementor session) {
|
||||
CacheItem cachedItem = null;
|
||||
final CacheGetEvent cacheGetEvent = JfrEventManager.beginCacheGetEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cacheGetEvent = eventManager.beginCacheGetEvent();
|
||||
try {
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
cachedItem = (CacheItem) cacheRegion.getFromCache( key, session );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCacheGetEvent(
|
||||
eventManager.completeCacheGetEvent(
|
||||
cacheGetEvent,
|
||||
session,
|
||||
cacheRegion,
|
||||
|
|
|
@ -14,9 +14,8 @@ import org.hibernate.cache.spi.TimestampsRegion;
|
|||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
@ -61,7 +60,8 @@ public class TimestampsCacheEnabledImpl implements TimestampsCache {
|
|||
if ( debugEnabled ) {
|
||||
log.debugf( "Pre-invalidating space [%s], timestamp: %s", space, ts );
|
||||
}
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
|
||||
|
@ -70,12 +70,12 @@ public class TimestampsCacheEnabledImpl implements TimestampsCache {
|
|||
timestampsRegion.putIntoCache( space, ts, session );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
timestampsRegion,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.TIMESTAMP_PRE_INVALIDATE
|
||||
EventManager.CacheActionDescription.TIMESTAMP_PRE_INVALIDATE
|
||||
);
|
||||
eventListenerManager.cachePutEnd();
|
||||
}
|
||||
|
@ -102,18 +102,19 @@ public class TimestampsCacheEnabledImpl implements TimestampsCache {
|
|||
}
|
||||
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
timestampsRegion.putIntoCache( space, ts, session );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
timestampsRegion,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.TIMESTAMP_INVALIDATE
|
||||
EventManager.CacheActionDescription.TIMESTAMP_INVALIDATE
|
||||
);
|
||||
eventListenerManager.cachePutEnd();
|
||||
|
||||
|
@ -193,13 +194,14 @@ public class TimestampsCacheEnabledImpl implements TimestampsCache {
|
|||
|
||||
private Long getLastUpdateTimestampForSpace(String space, SharedSessionContractImplementor session) {
|
||||
Long ts = null;
|
||||
final CacheGetEvent cacheGetEvent = JfrEventManager.beginCacheGetEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cacheGetEvent = eventManager.beginCacheGetEvent();
|
||||
try {
|
||||
session.getEventListenerManager().cacheGetStart();
|
||||
ts = (Long) timestampsRegion.getFromCache( space, session );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCacheGetEvent(
|
||||
eventManager.completeCacheGetEvent(
|
||||
cacheGetEvent,
|
||||
session,
|
||||
timestampsRegion,
|
||||
|
|
|
@ -12,8 +12,8 @@ import org.hibernate.cache.MutableCacheKeyBuilder;
|
|||
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.metamodel.mapping.JdbcMapping;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
@ -46,12 +46,13 @@ public final class CacheHelper {
|
|||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
Object cachedValue = null;
|
||||
eventListenerManager.cacheGetStart();
|
||||
final CacheGetEvent cacheGetEvent = JfrEventManager.beginCacheGetEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cacheGetEvent = eventManager.beginCacheGetEvent();
|
||||
try {
|
||||
cachedValue = cacheAccess.get( session, cacheKey );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCacheGetEvent(
|
||||
eventManager.completeCacheGetEvent(
|
||||
cacheGetEvent,
|
||||
session,
|
||||
cacheAccess.getRegion(),
|
||||
|
@ -72,12 +73,13 @@ public final class CacheHelper {
|
|||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
Object cachedValue = null;
|
||||
eventListenerManager.cacheGetStart();
|
||||
final CacheGetEvent cacheGetEvent = JfrEventManager.beginCacheGetEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cacheGetEvent = eventManager.beginCacheGetEvent();
|
||||
try {
|
||||
cachedValue = cacheAccess.get( session, cacheKey );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCacheGetEvent(
|
||||
eventManager.completeCacheGetEvent(
|
||||
cacheGetEvent,
|
||||
session,
|
||||
cacheAccess.getRegion(),
|
||||
|
|
|
@ -23,8 +23,8 @@ import org.hibernate.engine.spi.PersistenceContext;
|
|||
import org.hibernate.engine.spi.Resolution;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.mapping.NaturalIdLogging;
|
||||
import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
||||
|
@ -267,7 +267,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
|
||||
final SessionFactoryImplementor factory = s.getFactory();
|
||||
final StatisticsImplementor statistics = factory.getStatistics();
|
||||
|
||||
final EventManager eventManager = s.getEventManager();
|
||||
switch ( source ) {
|
||||
case LOAD: {
|
||||
if ( CacheHelper.fromSharedCache( s, cacheKey, persister, cacheAccess ) != null ) {
|
||||
|
@ -275,7 +275,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
return;
|
||||
}
|
||||
boolean put = false;
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
put = cacheAccess.putFromLoad(
|
||||
s,
|
||||
|
@ -292,14 +292,14 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
}
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session(),
|
||||
cacheAccess,
|
||||
rootEntityPersister,
|
||||
put,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_LOAD
|
||||
EventManager.CacheActionDescription.ENTITY_LOAD
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -307,7 +307,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
}
|
||||
case INSERT: {
|
||||
boolean put = false;
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
|
||||
try {
|
||||
put = cacheAccess.insert( s, cacheKey, id );
|
||||
|
@ -319,14 +319,14 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
}
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session(),
|
||||
cacheAccess,
|
||||
rootEntityPersister,
|
||||
put,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_INSERT
|
||||
EventManager.CacheActionDescription.ENTITY_INSERT
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -360,7 +360,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
|
||||
final SoftLock lock = cacheAccess.lockItem( s, cacheKey, null );
|
||||
boolean put = false;
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
put = cacheAccess.update( s, cacheKey, id );
|
||||
if ( put && statistics.isStatisticsEnabled() ) {
|
||||
|
@ -371,14 +371,14 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
}
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session(),
|
||||
cacheAccess,
|
||||
rootEntityPersister,
|
||||
put,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
EventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -387,7 +387,7 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
cacheAccess.unlockItem( s, previousCacheKey, removalLock );
|
||||
if (success) {
|
||||
boolean putAfterUpdate = false;
|
||||
final CachePutEvent cachePutEventAfterUpdate = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEventAfterUpdate = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
putAfterUpdate = cacheAccess.afterUpdate(
|
||||
s,
|
||||
|
@ -404,14 +404,14 @@ public class NaturalIdResolutionsImpl implements NaturalIdResolutions, Serializa
|
|||
}
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEventAfterUpdate,
|
||||
session(),
|
||||
cacheAccess,
|
||||
rootEntityPersister,
|
||||
putAfterUpdate,
|
||||
true,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_AFTER_UPDATE
|
||||
EventManager.CacheActionDescription.ENTITY_AFTER_UPDATE
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,10 @@ import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
|
||||
import static org.hibernate.engine.jdbc.JdbcLogging.JDBC_MESSAGE_LOGGER;
|
||||
import static org.hibernate.engine.jdbc.batch.JdbcBatchLogging.BATCH_LOGGER;
|
||||
|
@ -257,7 +258,8 @@ public class BatchImpl implements Batch {
|
|||
}
|
||||
|
||||
//noinspection deprecation
|
||||
final JdbcObserver observer = jdbcCoordinator.getJdbcSessionOwner().getJdbcSessionContext().getObserver();
|
||||
final JdbcSessionOwner jdbcSessionOwner = jdbcCoordinator.getJdbcSessionOwner();
|
||||
final JdbcObserver observer = jdbcSessionOwner.getJdbcSessionContext().getObserver();
|
||||
try {
|
||||
getStatementGroup().forEachStatement( (tableName, statementDetails) -> {
|
||||
final String sql = statementDetails.getSqlString();
|
||||
|
@ -270,13 +272,14 @@ public class BatchImpl implements Batch {
|
|||
try {
|
||||
if ( statementDetails.getMutatingTableDetails().isIdentifierTable() ) {
|
||||
final int[] rowCounts;
|
||||
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = JfrEventManager.beginJdbcBatchExecutionEvent();
|
||||
final EventManager eventManager = jdbcSessionOwner.getEventManager();
|
||||
final HibernateEvent jdbcBatchExecutionEvent = eventManager.beginJdbcBatchExecutionEvent();
|
||||
try {
|
||||
observer.jdbcExecuteBatchStart();
|
||||
rowCounts = statement.executeBatch();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcBatchExecutionEvent( jdbcBatchExecutionEvent, sql );
|
||||
eventManager.completeJdbcBatchExecutionEvent( jdbcBatchExecutionEvent, sql );
|
||||
observer.jdbcExecuteBatchEnd();
|
||||
}
|
||||
checkRowCounts( rowCounts, statementDetails );
|
||||
|
|
|
@ -26,6 +26,8 @@ import org.hibernate.engine.jdbc.internal.JdbcCoordinatorImpl;
|
|||
import org.hibernate.engine.jdbc.internal.JdbcServicesImpl;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.event.internal.EmptyEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.jdbc.AbstractReturningWork;
|
||||
import org.hibernate.jpa.internal.MutableJpaComplianceImpl;
|
||||
|
@ -635,6 +637,11 @@ public class JdbcEnvironmentInitiator implements StandardServiceInitiator<JdbcEn
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return EmptyEventManager.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScrollableResultSetsEnabled() {
|
||||
return false;
|
||||
|
|
|
@ -14,10 +14,11 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.MutationStatementPreparer;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor;
|
||||
|
||||
/**
|
||||
|
@ -94,17 +95,19 @@ public class MutationStatementPreparerImpl implements MutationStatementPreparer
|
|||
try {
|
||||
final PreparedStatement preparedStatement;
|
||||
//noinspection deprecation
|
||||
final JdbcObserver observer = jdbcCoordinator.getJdbcSessionOwner()
|
||||
final JdbcSessionOwner jdbcSessionOwner = jdbcCoordinator.getJdbcSessionOwner();
|
||||
final JdbcObserver observer = jdbcSessionOwner
|
||||
.getJdbcSessionContext()
|
||||
.getObserver();
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = JfrEventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
final EventManager eventManager = jdbcSessionOwner.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementCreation = eventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
try {
|
||||
observer.jdbcPrepareStatementStart();
|
||||
preparedStatement = doPrepare();
|
||||
setStatementTimeout( preparedStatement );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
eventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
observer.jdbcPrepareStatementEnd();
|
||||
}
|
||||
postProcess( preparedStatement );
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
*/
|
||||
package org.hibernate.engine.jdbc.internal;
|
||||
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
@ -18,8 +17,8 @@ import org.hibernate.engine.jdbc.spi.JdbcServices;
|
|||
import org.hibernate.engine.jdbc.spi.ResultSetReturn;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
|
||||
/**
|
||||
|
@ -55,13 +54,14 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
}
|
||||
try {
|
||||
final ResultSet rs;
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
rs = statement.executeQuery();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -94,13 +94,14 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
}
|
||||
try {
|
||||
final ResultSet rs;
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
rs = statement.executeQuery( sql );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -121,7 +122,8 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
}
|
||||
try {
|
||||
final ResultSet rs;
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
if ( !statement.execute() ) {
|
||||
|
@ -132,7 +134,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
rs = statement.getResultSet();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -153,7 +155,8 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
}
|
||||
try {
|
||||
final ResultSet rs;
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
if ( !statement.execute( sql ) ) {
|
||||
|
@ -164,7 +167,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
rs = statement.getResultSet();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -184,7 +187,8 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
if ( this.sqlStatementLogger.getLogSlowQuery() > 0 ) {
|
||||
executeStartNanos = System.nanoTime();
|
||||
}
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
return statement.executeUpdate();
|
||||
|
@ -193,7 +197,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
throw sqlExceptionHelper.convert( e, "could not execute statement", sql );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -206,7 +210,8 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
if ( this.sqlStatementLogger.getLogSlowQuery() > 0 ) {
|
||||
executeStartNanos = System.nanoTime();
|
||||
}
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = jdbcCoordinator.getJdbcSessionOwner().getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
jdbcExecuteStatementStart();
|
||||
return statement.executeUpdate( sql );
|
||||
|
@ -215,7 +220,7 @@ public class ResultSetReturnImpl implements ResultSetReturn {
|
|||
throw sqlExceptionHelper.convert( e, "could not execute statement", sql );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( sql, executeStartNanos, context() );
|
||||
}
|
||||
|
|
|
@ -17,10 +17,11 @@ import org.hibernate.ScrollMode;
|
|||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.jdbc.spi.SqlExceptionHelper;
|
||||
import org.hibernate.engine.jdbc.spi.StatementPreparer;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcObserver;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionContext;
|
||||
import org.hibernate.resource.jdbc.spi.JdbcSessionOwner;
|
||||
import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor;
|
||||
|
||||
/**
|
||||
|
@ -173,15 +174,17 @@ class StatementPreparerImpl implements StatementPreparer {
|
|||
jdbcServices.getSqlStatementLogger().logStatement( sql );
|
||||
|
||||
final PreparedStatement preparedStatement;
|
||||
final JdbcObserver observer = jdbcCoordinator.getJdbcSessionOwner().getJdbcSessionContext().getObserver();
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = JfrEventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
final JdbcSessionOwner jdbcSessionOwner = jdbcCoordinator.getJdbcSessionOwner();
|
||||
final JdbcObserver observer = jdbcSessionOwner.getJdbcSessionContext().getObserver();
|
||||
final EventManager eventManager = jdbcSessionOwner.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementCreation = eventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
try {
|
||||
observer.jdbcPrepareStatementStart();
|
||||
preparedStatement = doPrepare();
|
||||
setStatementTimeout( preparedStatement );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
eventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
observer.jdbcPrepareStatementEnd();
|
||||
}
|
||||
postProcess( preparedStatement );
|
||||
|
|
|
@ -38,6 +38,7 @@ import org.hibernate.engine.jdbc.LobCreator;
|
|||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.DeleteContext;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.MergeContext;
|
||||
|
@ -1223,6 +1224,11 @@ public class SessionDelegatorBaseImpl implements SessionImplementor {
|
|||
return delegate.getJdbcBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return delegate.getEventManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJdbcBatchSize(Integer jdbcBatchSize) {
|
||||
delegate.setJdbcBatchSize( jdbcBatchSize );
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.hibernate.engine.jdbc.LobCreator;
|
|||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.graph.RootGraph;
|
||||
import org.hibernate.jdbc.ReturningWork;
|
||||
import org.hibernate.jdbc.Work;
|
||||
|
@ -314,6 +315,11 @@ public class SharedSessionDelegatorBaseImpl implements SharedSessionContractImpl
|
|||
return delegate.getJdbcBatchSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return delegate.getEventManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJdbcBatchSize(Integer jdbcBatchSize) {
|
||||
delegate.setJdbcBatchSize( jdbcBatchSize );
|
||||
|
|
|
@ -11,10 +11,10 @@ import org.hibernate.HibernateException;
|
|||
import org.hibernate.engine.spi.ActionQueue;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.event.jfr.PartialFlushEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.AutoFlushEvent;
|
||||
import org.hibernate.event.spi.AutoFlushEventListener;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.stat.spi.StatisticsImplementor;
|
||||
|
@ -39,7 +39,8 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
public void onAutoFlush(AutoFlushEvent event) throws HibernateException {
|
||||
final EventSource source = event.getSession();
|
||||
final SessionEventListenerManager eventListenerManager = source.getEventListenerManager();
|
||||
final PartialFlushEvent partialFlushEvent = JfrEventManager.beginPartialFlushEvent();
|
||||
final EventManager eventManager = source.getEventManager();
|
||||
final HibernateEvent partialFlushEvent = eventManager.beginPartialFlushEvent();
|
||||
try {
|
||||
eventListenerManager.partialFlushStart();
|
||||
|
||||
|
@ -55,7 +56,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
|
||||
// note: performExecutions() clears all collectionXxxxtion
|
||||
// collections (the collection actions) in the session
|
||||
final org.hibernate.event.jfr.FlushEvent jfrFlushEvent = JfrEventManager.beginFlushEvent();
|
||||
final HibernateEvent flushEvent = eventManager.beginFlushEvent();
|
||||
try {
|
||||
performExecutions( source );
|
||||
postFlush( source );
|
||||
|
@ -63,7 +64,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
postPostFlush( source );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeFlushEvent( jfrFlushEvent, event, true );
|
||||
eventManager.completeFlushEvent( flushEvent, event, true );
|
||||
}
|
||||
final StatisticsImplementor statistics = source.getFactory().getStatistics();
|
||||
if ( statistics.isStatisticsEnabled() ) {
|
||||
|
@ -78,7 +79,7 @@ public class DefaultAutoFlushEventListener extends AbstractFlushingEventListener
|
|||
}
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completePartialFlushEvent( partialFlushEvent, event );
|
||||
eventManager.completePartialFlushEvent( partialFlushEvent, event );
|
||||
eventListenerManager.partialFlushEnd(
|
||||
event.getNumberOfEntitiesProcessed(),
|
||||
event.getNumberOfEntitiesProcessed()
|
||||
|
|
|
@ -24,8 +24,8 @@ import org.hibernate.engine.spi.SelfDirtinessTracker;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SessionImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.jfr.DirtyCalculationEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.FlushEntityEvent;
|
||||
import org.hibernate.event.spi.FlushEntityEventListener;
|
||||
|
@ -484,7 +484,8 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
|
|||
final SessionImplementor session = event.getSession();
|
||||
boolean dirtyCheckPossible;
|
||||
int[] dirtyProperties = null;
|
||||
final DirtyCalculationEvent dirtyCalculationEvent = JfrEventManager.beginDirtyCalculationEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent dirtyCalculationEvent = eventManager.beginDirtyCalculationEvent();
|
||||
final EntityEntry entry = event.getEntityEntry();
|
||||
final EntityPersister persister = entry.getPersister();
|
||||
try {
|
||||
|
@ -535,7 +536,7 @@ public class DefaultFlushEntityEventListener implements FlushEntityEventListener
|
|||
event.setDirtyCheckPossible( dirtyCheckPossible );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeDirtyCalculationEvent( dirtyCalculationEvent, session, persister, entry, dirtyProperties );
|
||||
eventManager.completeDirtyCalculationEvent( dirtyCalculationEvent, session, persister, entry, dirtyProperties );
|
||||
session.getEventListenerManager().dirtyCalculationEnd( dirtyProperties != null );
|
||||
}
|
||||
return dirtyProperties;
|
||||
|
|
|
@ -8,7 +8,8 @@ package org.hibernate.event.internal;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.PersistenceContext;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.event.spi.FlushEvent;
|
||||
import org.hibernate.event.spi.FlushEventListener;
|
||||
|
@ -29,9 +30,10 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
|
|||
public void onFlush(FlushEvent event) throws HibernateException {
|
||||
final EventSource source = event.getSession();
|
||||
final PersistenceContext persistenceContext = source.getPersistenceContextInternal();
|
||||
final EventManager eventManager = source.getEventManager();
|
||||
if ( persistenceContext.getNumberOfManagedEntities() > 0
|
||||
|| persistenceContext.getCollectionEntriesSize() > 0 ) {
|
||||
final org.hibernate.event.jfr.FlushEvent jfrFlushEvent = JfrEventManager.beginFlushEvent();
|
||||
final HibernateEvent flushEvent = eventManager.beginFlushEvent();
|
||||
try {
|
||||
source.getEventListenerManager().flushStart();
|
||||
|
||||
|
@ -40,7 +42,7 @@ public class DefaultFlushEventListener extends AbstractFlushingEventListener imp
|
|||
postFlush( source );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeFlushEvent( jfrFlushEvent, event );
|
||||
eventManager.completeFlushEvent( flushEvent, event );
|
||||
source.getEventListenerManager().flushEnd(
|
||||
event.getNumberOfEntitiesProcessed(),
|
||||
event.getNumberOfCollectionsProcessed()
|
||||
|
|
|
@ -0,0 +1,232 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.internal;
|
||||
|
||||
import org.hibernate.cache.spi.Region;
|
||||
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.spi.AutoFlushEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.FlushEvent;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
||||
public class EmptyEventManager implements EventManager {
|
||||
|
||||
public static final EmptyEventManager INSTANCE = new EmptyEventManager();
|
||||
|
||||
private EmptyEventManager(){
|
||||
|
||||
}
|
||||
@Override
|
||||
public HibernateEvent beginSessionOpenEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeSessionOpenEvent(HibernateEvent sessionOpenEvent, SharedSessionContractImplementor session) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginSessionClosedEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeSessionClosedEvent(
|
||||
HibernateEvent sessionClosedEvent,
|
||||
SharedSessionContractImplementor session) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginJdbcConnectionAcquisitionEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeJdbcConnectionAcquisitionEvent(
|
||||
HibernateEvent jdbcConnectionAcquisitionEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginJdbcConnectionReleaseEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeJdbcConnectionReleaseEvent(
|
||||
HibernateEvent jdbcConnectionReleaseEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginJdbcPreparedStatementCreationEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeJdbcPreparedStatementCreationEvent(
|
||||
HibernateEvent jdbcPreparedStatementCreation,
|
||||
String preparedStatementSql) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginJdbcPreparedStatementExecutionEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeJdbcPreparedStatementExecutionEvent(
|
||||
HibernateEvent jdbcPreparedStatementExecutionEvent,
|
||||
String preparedStatementSql) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginJdbcBatchExecutionEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeJdbcBatchExecutionEvent(HibernateEvent jdbcBatchExecutionEvent, String statementSql) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginCachePutEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
boolean isNatualId,
|
||||
CacheActionDescription description) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
CollectionPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginCacheGetEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean hit) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
EntityPersister persister,
|
||||
boolean isNaturalKey,
|
||||
boolean hit) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
CollectionPersister persister,
|
||||
boolean hit) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginFlushEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeFlushEvent(HibernateEvent flushEvent, FlushEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeFlushEvent(HibernateEvent flushEvent, FlushEvent event, boolean autoFlush) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginPartialFlushEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completePartialFlushEvent(HibernateEvent flushEvent, AutoFlushEvent event) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public HibernateEvent beginDirtyCalculationEvent() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void completeDirtyCalculationEvent(
|
||||
HibernateEvent dirtyCalculationEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
EntityPersister persister,
|
||||
EntityEntry entry,
|
||||
int[] dirtyProperties) {
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.spi;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
import org.hibernate.cache.spi.Region;
|
||||
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.service.JavaServiceLoadable;
|
||||
|
||||
@JavaServiceLoadable
|
||||
@Incubating
|
||||
public interface EventManager {
|
||||
HibernateEvent beginSessionOpenEvent();
|
||||
|
||||
void completeSessionOpenEvent(
|
||||
HibernateEvent sessionOpenEvent,
|
||||
SharedSessionContractImplementor session);
|
||||
|
||||
HibernateEvent beginSessionClosedEvent();
|
||||
|
||||
void completeSessionClosedEvent(
|
||||
HibernateEvent sessionClosedEvent,
|
||||
SharedSessionContractImplementor session);
|
||||
|
||||
HibernateEvent beginJdbcConnectionAcquisitionEvent();
|
||||
|
||||
void completeJdbcConnectionAcquisitionEvent(
|
||||
HibernateEvent jdbcConnectionAcquisitionEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId);
|
||||
|
||||
HibernateEvent beginJdbcConnectionReleaseEvent();
|
||||
|
||||
void completeJdbcConnectionReleaseEvent(
|
||||
HibernateEvent jdbcConnectionReleaseEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId);
|
||||
|
||||
HibernateEvent beginJdbcPreparedStatementCreationEvent();
|
||||
|
||||
void completeJdbcPreparedStatementCreationEvent(
|
||||
HibernateEvent jdbcPreparedStatementCreation,
|
||||
String preparedStatementSql);
|
||||
|
||||
HibernateEvent beginJdbcPreparedStatementExecutionEvent();
|
||||
|
||||
void completeJdbcPreparedStatementExecutionEvent(
|
||||
HibernateEvent jdbcPreparedStatementExecutionEvent,
|
||||
String preparedStatementSql);
|
||||
|
||||
HibernateEvent beginJdbcBatchExecutionEvent();
|
||||
|
||||
void completeJdbcBatchExecutionEvent(
|
||||
HibernateEvent jdbcBatchExecutionEvent,
|
||||
String statementSql);
|
||||
|
||||
HibernateEvent beginCachePutEvent();
|
||||
|
||||
void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description);
|
||||
|
||||
void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description);
|
||||
|
||||
void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
boolean isNatualId,
|
||||
CacheActionDescription description);
|
||||
|
||||
void completeCachePutEvent(
|
||||
HibernateEvent cachePutEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
CollectionPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description);
|
||||
|
||||
HibernateEvent beginCacheGetEvent();
|
||||
|
||||
void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean hit);
|
||||
|
||||
void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
EntityPersister persister,
|
||||
boolean isNaturalKey,
|
||||
boolean hit);
|
||||
|
||||
void completeCacheGetEvent(
|
||||
HibernateEvent cacheGetEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
CollectionPersister persister,
|
||||
boolean hit);
|
||||
|
||||
HibernateEvent beginFlushEvent();
|
||||
|
||||
void completeFlushEvent(
|
||||
HibernateEvent flushEvent,
|
||||
org.hibernate.event.spi.FlushEvent event);
|
||||
|
||||
void completeFlushEvent(
|
||||
HibernateEvent flushEvent,
|
||||
org.hibernate.event.spi.FlushEvent event,
|
||||
boolean autoFlush);
|
||||
|
||||
HibernateEvent beginPartialFlushEvent();
|
||||
|
||||
void completePartialFlushEvent(
|
||||
HibernateEvent flushEvent,
|
||||
AutoFlushEvent event);
|
||||
|
||||
HibernateEvent beginDirtyCalculationEvent();
|
||||
|
||||
void completeDirtyCalculationEvent(
|
||||
HibernateEvent dirtyCalculationEvent,
|
||||
SharedSessionContractImplementor session,
|
||||
EntityPersister persister,
|
||||
EntityEntry entry,
|
||||
int[] dirtyProperties);
|
||||
|
||||
|
||||
enum CacheActionDescription {
|
||||
ENTITY_INSERT( "Entity Insert" ),
|
||||
ENTITY_AFTER_INSERT( "Entity After Insert" ),
|
||||
ENTITY_UPDATE( "Entity Update" ),
|
||||
ENTITY_LOAD( "Entity Load" ),
|
||||
ENTITY_AFTER_UPDATE( "Entity After Update" ),
|
||||
TIMESTAMP_PRE_INVALIDATE( "Timestamp Pre Invalidate" ),
|
||||
TIMESTAMP_INVALIDATE( "Timestamp Invalidate" ),
|
||||
COLLECTION_INSERT( "Collection Insert" ),
|
||||
QUERY_RESULT( "Query Result" );
|
||||
|
||||
|
||||
private final String text;
|
||||
|
||||
CacheActionDescription(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.spi;
|
||||
|
||||
import org.hibernate.Incubating;
|
||||
|
||||
@Incubating
|
||||
public interface HibernateEvent {
|
||||
}
|
|
@ -34,9 +34,8 @@ import org.hibernate.engine.jdbc.internal.FormatStyle;
|
|||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.id.ExportableColumn;
|
||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||
import org.hibernate.id.IntegralDataTypeHolder;
|
||||
|
@ -570,7 +569,7 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
new AbstractReturningWork<>() {
|
||||
@Override
|
||||
public IntegralDataTypeHolder execute(Connection connection) throws SQLException {
|
||||
return nextValue( connection, statementLogger, statsCollector );
|
||||
return nextValue( connection, statementLogger, statsCollector, session );
|
||||
}
|
||||
},
|
||||
true
|
||||
|
@ -588,15 +587,16 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
private IntegralDataTypeHolder nextValue(
|
||||
Connection connection,
|
||||
SqlStatementLogger logger,
|
||||
SessionEventListenerManager listener)
|
||||
SessionEventListenerManager listener,
|
||||
SharedSessionContractImplementor session)
|
||||
throws SQLException {
|
||||
final IntegralDataTypeHolder value = makeValue();
|
||||
int rows;
|
||||
do {
|
||||
|
||||
try ( PreparedStatement selectPS = prepareStatement( connection, selectQuery, logger, listener ) ) {
|
||||
try ( PreparedStatement selectPS = prepareStatement( connection, selectQuery, logger, listener, session ) ) {
|
||||
selectPS.setString( 1, segmentValue );
|
||||
final ResultSet selectRS = executeQuery( selectPS, listener, selectQuery );
|
||||
final ResultSet selectRS = executeQuery( selectPS, listener, selectQuery, session );
|
||||
if ( !selectRS.next() ) {
|
||||
long initializationValue;
|
||||
if ( storeLastUsedValue ) {
|
||||
|
@ -607,11 +607,11 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
}
|
||||
value.initialize( initializationValue );
|
||||
|
||||
try ( PreparedStatement statement = prepareStatement( connection, insertQuery, logger, listener ) ) {
|
||||
try ( PreparedStatement statement = prepareStatement( connection, insertQuery, logger, listener, session ) ) {
|
||||
LOG.tracef( "binding parameter [%s] - [%s]", 1, segmentValue );
|
||||
statement.setString( 1, segmentValue );
|
||||
value.bind( statement, 2 );
|
||||
executeUpdate( statement, listener, insertQuery);
|
||||
executeUpdate( statement, listener, insertQuery, session);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -632,7 +632,7 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
}
|
||||
|
||||
|
||||
try ( PreparedStatement statement = prepareStatement( connection, updateQuery, logger, listener ) ) {
|
||||
try ( PreparedStatement statement = prepareStatement( connection, updateQuery, logger, listener, session ) ) {
|
||||
final IntegralDataTypeHolder updateValue = value.copy();
|
||||
if ( optimizer.applyIncrementSizeToSourceValues() ) {
|
||||
updateValue.add( incrementSize );
|
||||
|
@ -643,7 +643,7 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
updateValue.bind( statement, 1 );
|
||||
value.bind( statement, 2 );
|
||||
statement.setString( 3, segmentValue );
|
||||
rows = executeUpdate( statement, listener, updateQuery );
|
||||
rows = executeUpdate( statement, listener, updateQuery, session );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
LOG.unableToUpdateQueryHiValue( physicalTableName.render(), e );
|
||||
|
@ -665,39 +665,51 @@ public class TableGenerator implements PersistentIdentifierGenerator {
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger logger,
|
||||
SessionEventListenerManager listener) throws SQLException {
|
||||
SessionEventListenerManager listener,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
logger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = JfrEventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementCreation = eventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
try {
|
||||
listener.jdbcPrepareStatementStart();
|
||||
return connection.prepareStatement( sql );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
eventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
listener.jdbcPrepareStatementEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager listener, String sql ) throws SQLException {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
private int executeUpdate(
|
||||
PreparedStatement ps,
|
||||
SessionEventListenerManager listener,
|
||||
String sql,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
listener.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
listener.jdbcExecuteStatementEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager listener, String sql ) throws SQLException {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
private ResultSet executeQuery(
|
||||
PreparedStatement ps,
|
||||
SessionEventListenerManager listener,
|
||||
String sql,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
listener.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
listener.jdbcExecuteStatementEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,9 +26,8 @@ import org.hibernate.engine.jdbc.internal.FormatStyle;
|
|||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.id.ExportableColumn;
|
||||
import org.hibernate.id.IdentifierGenerationException;
|
||||
import org.hibernate.id.IdentifierGeneratorHelper;
|
||||
|
@ -144,9 +143,15 @@ public class TableStructure implements DatabaseStructure {
|
|||
connection,
|
||||
selectQuery,
|
||||
statementLogger,
|
||||
statsCollector
|
||||
statsCollector,
|
||||
session
|
||||
)) {
|
||||
final ResultSet selectRS = executeQuery( selectStatement, statsCollector, selectQuery );
|
||||
final ResultSet selectRS = executeQuery(
|
||||
selectStatement,
|
||||
statsCollector,
|
||||
selectQuery,
|
||||
session
|
||||
);
|
||||
if ( !selectRS.next() ) {
|
||||
final String err = "could not read a hi value - you need to populate the table: " + physicalTableName;
|
||||
LOG.error( err );
|
||||
|
@ -165,13 +170,14 @@ public class TableStructure implements DatabaseStructure {
|
|||
connection,
|
||||
updateQuery,
|
||||
statementLogger,
|
||||
statsCollector
|
||||
statsCollector,
|
||||
session
|
||||
)) {
|
||||
final int increment = applyIncrementSizeToSourceValues ? incrementSize : 1;
|
||||
final IntegralDataTypeHolder updateValue = value.copy().add( increment );
|
||||
updateValue.bind( updatePS, 1 );
|
||||
value.bind( updatePS, 2 );
|
||||
rows = executeUpdate( updatePS, statsCollector, updateQuery );
|
||||
rows = executeUpdate( updatePS, statsCollector, updateQuery, session );
|
||||
}
|
||||
catch (SQLException e) {
|
||||
LOG.unableToUpdateQueryHiValue( physicalTableName.render(), e );
|
||||
|
@ -199,40 +205,52 @@ public class TableStructure implements DatabaseStructure {
|
|||
Connection connection,
|
||||
String sql,
|
||||
SqlStatementLogger statementLogger,
|
||||
SessionEventListenerManager statsCollector) throws SQLException {
|
||||
SessionEventListenerManager statsCollector,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
statementLogger.logStatement( sql, FormatStyle.BASIC.getFormatter() );
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = JfrEventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementCreation = eventManager.beginJdbcPreparedStatementCreationEvent();
|
||||
try {
|
||||
statsCollector.jdbcPrepareStatementStart();
|
||||
return connection.prepareStatement( sql );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
eventManager.completeJdbcPreparedStatementCreationEvent( jdbcPreparedStatementCreation, sql );
|
||||
statsCollector.jdbcPrepareStatementEnd();
|
||||
}
|
||||
}
|
||||
|
||||
private int executeUpdate(PreparedStatement ps, SessionEventListenerManager statsCollector, String sql ) throws SQLException {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
private int executeUpdate(
|
||||
PreparedStatement ps,
|
||||
SessionEventListenerManager statsCollector,
|
||||
String sql,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeUpdate();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
statsCollector.jdbcExecuteStatementEnd();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private ResultSet executeQuery(PreparedStatement ps, SessionEventListenerManager statsCollector, String sql ) throws SQLException {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
private ResultSet executeQuery(
|
||||
PreparedStatement ps,
|
||||
SessionEventListenerManager statsCollector,
|
||||
String sql,
|
||||
SharedSessionContractImplementor session) throws SQLException {
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
statsCollector.jdbcExecuteStatementStart();
|
||||
return ps.executeQuery();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, sql );
|
||||
statsCollector.jdbcExecuteStatementEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,6 +43,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor;
|
|||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.transaction.internal.TransactionImpl;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.graph.RootGraph;
|
||||
import org.hibernate.graph.internal.RootGraphImpl;
|
||||
import org.hibernate.graph.spi.RootGraphImplementor;
|
||||
|
@ -176,6 +177,7 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
|
||||
public AbstractSharedSessionContract(SessionFactoryImpl factory, SessionCreationOptions options) {
|
||||
this.factory = factory;
|
||||
|
||||
fastSessionServices = factory.getFastSessionServices();
|
||||
cacheTransactionSync = factory.getCache().getRegionFactory().createTransactionContext( this );
|
||||
flushMode = options.getInitialSessionFlushMode();
|
||||
|
@ -1328,6 +1330,11 @@ public abstract class AbstractSharedSessionContract implements SharedSessionCont
|
|||
return jdbcBatchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventManager getEventManager() {
|
||||
return fastSessionServices.getEventManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJdbcBatchSize(Integer jdbcBatchSize) {
|
||||
this.jdbcBatchSize = jdbcBatchSize;
|
||||
|
|
|
@ -15,9 +15,8 @@ import org.hibernate.SessionEventListener;
|
|||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcConnectionAcquisitionEvent;
|
||||
import org.hibernate.event.jfr.JdbcConnectionReleaseEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -46,13 +45,14 @@ public class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Ser
|
|||
throw new HibernateException( "Tenant identifier required" );
|
||||
}
|
||||
|
||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = JfrEventManager.beginJdbcConnectionAcquisitionEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcConnectionAcquisitionEvent = eventManager.beginJdbcConnectionAcquisitionEvent();
|
||||
try {
|
||||
listener.jdbcConnectionAcquisitionStart();
|
||||
return connectionProvider.getConnection( tenantIdentifier );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcConnectionAcquisitionEvent(
|
||||
eventManager.completeJdbcConnectionAcquisitionEvent(
|
||||
jdbcConnectionAcquisitionEvent,
|
||||
session,
|
||||
tenantIdentifier
|
||||
|
@ -67,13 +67,14 @@ public class ContextualJdbcConnectionAccess implements JdbcConnectionAccess, Ser
|
|||
throw new HibernateException( "Tenant identifier required" );
|
||||
}
|
||||
|
||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = JfrEventManager.beginJdbcConnectionReleaseEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcConnectionReleaseEvent = eventManager.beginJdbcConnectionReleaseEvent();
|
||||
try {
|
||||
listener.jdbcConnectionReleaseStart();
|
||||
connectionProvider.releaseConnection( tenantIdentifier, connection );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcConnectionReleaseEvent( jdbcConnectionReleaseEvent, session, tenantIdentifier );
|
||||
eventManager.completeJdbcConnectionReleaseEvent( jdbcConnectionReleaseEvent, session, tenantIdentifier );
|
||||
listener.jdbcConnectionReleaseEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.internal;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
@ -24,6 +25,8 @@ import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
|
|||
import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.event.internal.EmptyEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.service.spi.EventListenerGroup;
|
||||
import org.hibernate.event.service.spi.EventListenerRegistry;
|
||||
import org.hibernate.event.spi.AutoFlushEventListener;
|
||||
|
@ -184,6 +187,7 @@ public final class FastSessionServices {
|
|||
private final FormatMapper xmlFormatMapper;
|
||||
private final MutationExecutorService mutationExecutorService;
|
||||
private final JdbcValuesMappingProducerProvider jdbcValuesMappingProducerProvider;
|
||||
private final EventManager eventManager;
|
||||
|
||||
FastSessionServices(SessionFactoryImplementor sessionFactory) {
|
||||
Objects.requireNonNull( sessionFactory );
|
||||
|
@ -269,6 +273,10 @@ public final class FastSessionServices {
|
|||
this.jsonFormatMapper = sessionFactoryOptions.getJsonFormatMapper();
|
||||
this.xmlFormatMapper = sessionFactoryOptions.getXmlFormatMapper();
|
||||
this.batchBuilder = serviceRegistry.getService( BatchBuilder.class );
|
||||
final Collection<EventManager> eventManagers = classLoaderService.loadJavaServices( EventManager.class );
|
||||
this.eventManager = eventManagers.isEmpty()
|
||||
? EmptyEventManager.INSTANCE
|
||||
: eventManagers.iterator().next();
|
||||
}
|
||||
|
||||
private static FlushMode initializeDefaultFlushMode(Map<String, Object> defaultSessionProperties) {
|
||||
|
@ -377,6 +385,10 @@ public final class FastSessionServices {
|
|||
return this.jdbcValuesMappingProducerProvider;
|
||||
}
|
||||
|
||||
public EventManager getEventManager() {
|
||||
return eventManager;
|
||||
}
|
||||
|
||||
public boolean useStreamForLobBinding() {
|
||||
return useStreamForLobBinding;
|
||||
}
|
||||
|
|
|
@ -15,9 +15,8 @@ import org.hibernate.SessionEventListener;
|
|||
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.JdbcConnectionAcquisitionEvent;
|
||||
import org.hibernate.event.jfr.JdbcConnectionReleaseEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
|
@ -40,13 +39,14 @@ public class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess,
|
|||
|
||||
@Override
|
||||
public Connection obtainConnection() throws SQLException {
|
||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = JfrEventManager.beginJdbcConnectionAcquisitionEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcConnectionAcquisitionEvent = eventManager.beginJdbcConnectionAcquisitionEvent();
|
||||
try {
|
||||
listener.jdbcConnectionAcquisitionStart();
|
||||
return connectionProvider.getConnection();
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcConnectionAcquisitionEvent(
|
||||
eventManager.completeJdbcConnectionAcquisitionEvent(
|
||||
jdbcConnectionAcquisitionEvent,
|
||||
session,
|
||||
null
|
||||
|
@ -57,13 +57,14 @@ public class NonContextualJdbcConnectionAccess implements JdbcConnectionAccess,
|
|||
|
||||
@Override
|
||||
public void releaseConnection(Connection connection) throws SQLException {
|
||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = JfrEventManager.beginJdbcConnectionReleaseEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcConnectionReleaseEvent = eventManager.beginJdbcConnectionReleaseEvent();
|
||||
try {
|
||||
listener.jdbcConnectionReleaseStart();
|
||||
connectionProvider.closeConnection( connection );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcConnectionReleaseEvent( jdbcConnectionReleaseEvent, session, null );
|
||||
eventManager.completeJdbcConnectionReleaseEvent( jdbcConnectionReleaseEvent, session, null );
|
||||
listener.jdbcConnectionReleaseEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,9 +68,8 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.engine.transaction.spi.TransactionImplementor;
|
||||
import org.hibernate.engine.transaction.spi.TransactionObserver;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.jfr.SessionClosedEvent;
|
||||
import org.hibernate.event.jfr.SessionOpenEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.AutoFlushEvent;
|
||||
import org.hibernate.event.spi.AutoFlushEventListener;
|
||||
import org.hibernate.event.spi.ClearEvent;
|
||||
|
@ -228,7 +227,7 @@ public class SessionImpl
|
|||
public SessionImpl(SessionFactoryImpl factory, SessionCreationOptions options) {
|
||||
super( factory, options );
|
||||
|
||||
final SessionOpenEvent sessionOpenEvent = JfrEventManager.beginSessionOpenEvent();
|
||||
final HibernateEvent sessionOpenEvent = getEventManager().beginSessionOpenEvent();
|
||||
|
||||
persistenceContext = createPersistenceContext();
|
||||
actionQueue = createActionQueue();
|
||||
|
@ -275,7 +274,7 @@ public class SessionImpl
|
|||
log.tracef( "Opened Session [%s] at timestamp: %s", getSessionIdentifier(), currentTimeMillis() );
|
||||
}
|
||||
|
||||
JfrEventManager.completeSessionOpenEvent( sessionOpenEvent, this );
|
||||
getEventManager().completeSessionOpenEvent( sessionOpenEvent, this );
|
||||
}
|
||||
|
||||
private FlushMode getInitialFlushMode() {
|
||||
|
@ -417,7 +416,8 @@ public class SessionImpl
|
|||
log.tracef( "Closing session [%s]", getSessionIdentifier() );
|
||||
}
|
||||
|
||||
final SessionClosedEvent sessionClosedEvent = JfrEventManager.beginSessionClosedEvent();
|
||||
final EventManager eventManager = getEventManager();
|
||||
final HibernateEvent sessionClosedEvent = eventManager.beginSessionClosedEvent();
|
||||
|
||||
// todo : we want this check if usage is JPA, but not native Hibernate usage
|
||||
final SessionFactoryImplementor sessionFactory = getSessionFactory();
|
||||
|
@ -442,7 +442,7 @@ public class SessionImpl
|
|||
statistics.closeSession();
|
||||
}
|
||||
|
||||
JfrEventManager.completeSessionClosedEvent( sessionClosedEvent, this );
|
||||
eventManager.completeSessionClosedEvent( sessionClosedEvent, this );
|
||||
}
|
||||
|
||||
private boolean isTransactionInProgressAndNotMarkedForRollback() {
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package org.hibernate.resource.jdbc.spi;
|
||||
|
||||
import org.hibernate.engine.jdbc.connections.spi.JdbcConnectionAccess;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.resource.transaction.spi.TransactionCoordinator;
|
||||
|
||||
/**
|
||||
|
@ -69,4 +70,6 @@ public interface JdbcSessionOwner {
|
|||
* @since 5.2
|
||||
*/
|
||||
Integer getJdbcBatchSize();
|
||||
|
||||
EventManager getEventManager();
|
||||
}
|
||||
|
|
|
@ -13,8 +13,8 @@ import java.util.function.Function;
|
|||
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.query.spi.QueryOptions;
|
||||
import org.hibernate.resource.jdbc.spi.LogicalConnectionImplementor;
|
||||
import org.hibernate.sql.exec.spi.ExecutionContext;
|
||||
|
@ -81,14 +81,15 @@ public class StandardJdbcMutationExecutor implements JdbcMutationExecutor {
|
|||
}
|
||||
|
||||
session.getEventListenerManager().jdbcExecuteStatementStart();
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
int rows = preparedStatement.executeUpdate();
|
||||
expectationCheck.accept( rows, preparedStatement );
|
||||
return rows;
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, finalSql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, finalSql );
|
||||
session.getEventListenerManager().jdbcExecuteStatementEnd();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ import org.hibernate.engine.spi.SessionEventListenerManager;
|
|||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.PreLoadEvent;
|
||||
import org.hibernate.event.spi.PreLoadEventListener;
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
|
@ -985,9 +985,10 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
|||
// 2) Session#clear + some form of load
|
||||
//
|
||||
// we need to be careful not to clobber the lock here in the cache so that it can be rolled back if need be
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
if ( persistenceContext.wasInsertedDuringTransaction( concreteDescriptor, entityIdentifier) ) {
|
||||
boolean update = false;
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
update = cacheAccess.update(
|
||||
session,
|
||||
|
@ -998,20 +999,20 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
|||
);
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheAccess,
|
||||
concreteDescriptor,
|
||||
update,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
EventManager.CacheActionDescription.ENTITY_UPDATE
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
boolean put = false;
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
put = cacheAccess.putFromLoad(
|
||||
|
@ -1024,13 +1025,13 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
|||
);
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheAccess,
|
||||
concreteDescriptor,
|
||||
put,
|
||||
JfrEventManager.CacheActionDescription.ENTITY_LOAD
|
||||
EventManager.CacheActionDescription.ENTITY_LOAD
|
||||
);
|
||||
final StatisticsImplementor statistics = factory.getStatistics();
|
||||
if ( put && statistics.isStatisticsEnabled() ) {
|
||||
|
|
|
@ -22,8 +22,8 @@ import org.hibernate.engine.spi.PersistenceContext;
|
|||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.metamodel.mapping.ModelPart;
|
||||
|
@ -288,7 +288,8 @@ public class ResultsHelper {
|
|||
// CollectionRegionAccessStrategy has no update, so avoid putting uncommitted data via putFromLoad
|
||||
if ( isPutFromLoad ) {
|
||||
final SessionEventListenerManager eventListenerManager = session.getEventListenerManager();
|
||||
final CachePutEvent cachePutEvent = JfrEventManager.beginCachePutEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent cachePutEvent = eventManager.beginCachePutEvent();
|
||||
boolean put = false;
|
||||
try {
|
||||
eventListenerManager.cachePutStart();
|
||||
|
@ -302,13 +303,13 @@ public class ResultsHelper {
|
|||
);
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeCachePutEvent(
|
||||
eventManager.completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
session,
|
||||
cacheAccess,
|
||||
collectionDescriptor,
|
||||
put,
|
||||
JfrEventManager.CacheActionDescription.COLLECTION_INSERT
|
||||
EventManager.CacheActionDescription.COLLECTION_INSERT
|
||||
);
|
||||
eventListenerManager.cachePutEnd();
|
||||
|
||||
|
|
|
@ -20,8 +20,9 @@ import org.hibernate.dialect.pagination.NoopLimitHandler;
|
|||
import org.hibernate.engine.jdbc.spi.SqlStatementLogger;
|
||||
import org.hibernate.engine.spi.SessionEventListenerManager;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.hibernate.query.spi.Limit;
|
||||
|
@ -223,6 +224,7 @@ public class DeferredResultSetAccess extends AbstractResultSetAccess {
|
|||
private void executeQuery() {
|
||||
final LogicalConnectionImplementor logicalConnection = getPersistenceContext().getJdbcCoordinator().getLogicalConnection();
|
||||
|
||||
final SharedSessionContractImplementor session = executionContext.getSession();
|
||||
try {
|
||||
LOG.tracef( "Executing query to retrieve ResultSet : %s", finalSql );
|
||||
// prepare the query
|
||||
|
@ -230,20 +232,21 @@ public class DeferredResultSetAccess extends AbstractResultSetAccess {
|
|||
|
||||
bindParameters( preparedStatement );
|
||||
|
||||
final SessionEventListenerManager eventListenerManager = executionContext.getSession()
|
||||
final SessionEventListenerManager eventListenerManager = session
|
||||
.getEventListenerManager();
|
||||
|
||||
long executeStartNanos = 0;
|
||||
if ( sqlStatementLogger.getLogSlowQuery() > 0 ) {
|
||||
executeStartNanos = System.nanoTime();
|
||||
}
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = JfrEventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
final EventManager eventManager = session.getEventManager();
|
||||
final HibernateEvent jdbcPreparedStatementExecutionEvent = eventManager.beginJdbcPreparedStatementExecutionEvent();
|
||||
try {
|
||||
eventListenerManager.jdbcExecuteStatementStart();
|
||||
resultSet = wrapResultSet( preparedStatement.executeQuery() );
|
||||
}
|
||||
finally {
|
||||
JfrEventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, finalSql );
|
||||
eventManager.completeJdbcPreparedStatementExecutionEvent( jdbcPreparedStatementExecutionEvent, finalSql );
|
||||
eventListenerManager.jdbcExecuteStatementEnd();
|
||||
sqlStatementLogger.logSlowQuery( finalSql, executeStartNanos, context() );
|
||||
}
|
||||
|
@ -259,7 +262,7 @@ public class DeferredResultSetAccess extends AbstractResultSetAccess {
|
|||
catch (RuntimeException e2) {
|
||||
e.addSuppressed( e2 );
|
||||
}
|
||||
throw executionContext.getSession().getJdbcServices().getSqlExceptionHelper().convert(
|
||||
throw session.getJdbcServices().getSqlExceptionHelper().convert(
|
||||
e,
|
||||
"JDBC exception executing SQL [" + finalSql + "]"
|
||||
);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
|
||||
description = 'Integration for JDK JFR into Hibernate O/RM'
|
||||
|
||||
apply from: rootProject.file( 'gradle/published-java-module.gradle' )
|
||||
|
||||
dependencies {
|
||||
implementation project( ':hibernate-core' )
|
||||
|
||||
testImplementation project( ':hibernate-testing' )
|
||||
testImplementation testLibs.jfrUnit
|
||||
}
|
||||
|
||||
|
||||
// JfrUnit requires JDJ 17
|
||||
compileTestJava.onlyIf{
|
||||
jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit
|
||||
}
|
||||
|
||||
test.onlyIf {
|
||||
jdkVersions.test.release.asInt() >= 17 && jdkVersions.explicit
|
||||
}
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -21,7 +22,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description( "Cache Get Executed" )
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class CacheGetEvent extends Event {
|
||||
public class CacheGetEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.CacheGet";
|
||||
|
||||
@Label( "Session Identifier" )
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -21,7 +22,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description( "Cache Put Executed" )
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class CachePutEvent extends Event {
|
||||
public class CachePutEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.CachePut";
|
||||
|
||||
@Label( "Session Identifier" )
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -15,33 +16,33 @@ import jdk.jfr.Label;
|
|||
import jdk.jfr.Name;
|
||||
import jdk.jfr.StackTrace;
|
||||
|
||||
@Name( DirtyCalculationEvent.NAME )
|
||||
@Label( "DirtyCalculationEvent Execution" )
|
||||
@Category( "Hibernate ORM" )
|
||||
@Description( "DirtyCalculationEvent Execution" )
|
||||
@Name(DirtyCalculationEvent.NAME)
|
||||
@Label("DirtyCalculationEvent Execution")
|
||||
@Category("Hibernate ORM")
|
||||
@Description("DirtyCalculationEvent Execution")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class DirtyCalculationEvent extends Event {
|
||||
public class DirtyCalculationEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.DirtyCalculationEvent";
|
||||
|
||||
@Label( "Session Identifier" )
|
||||
@Label("Session Identifier")
|
||||
public String sessionIdentifier;
|
||||
|
||||
@Label( "PartialFlushEvent time" )
|
||||
@Label("PartialFlushEvent time")
|
||||
public long executionTime;
|
||||
|
||||
@Label( "Entity Name" )
|
||||
@Label("Entity Name")
|
||||
public String entityName;
|
||||
|
||||
@Label( "Entity Status" )
|
||||
@Label("Entity Status")
|
||||
public String entityStatus;
|
||||
|
||||
@Label( "Found properties" )
|
||||
@Label("Found properties")
|
||||
public boolean dirty;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME ;
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public transient long startedAt;
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -15,33 +16,33 @@ import jdk.jfr.Label;
|
|||
import jdk.jfr.Name;
|
||||
import jdk.jfr.StackTrace;
|
||||
|
||||
@Name( FlushEvent.NAME )
|
||||
@Label( "Flush Execution" )
|
||||
@Category( "Hibernate ORM" )
|
||||
@Description( "Flush Execution" )
|
||||
@Name(FlushEvent.NAME)
|
||||
@Label("Flush Execution")
|
||||
@Category("Hibernate ORM")
|
||||
@Description("Flush Execution")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class FlushEvent extends Event {
|
||||
public class FlushEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.FlushEvent";
|
||||
|
||||
@Label( "Session Identifier" )
|
||||
@Label("Session Identifier")
|
||||
public String sessionIdentifier;
|
||||
|
||||
@Label( "Number Of Processed Entities" )
|
||||
@Label("Number Of Processed Entities")
|
||||
public int numberOfEntitiesProcessed;
|
||||
|
||||
@Label( "Number Of Processed Collectionc" )
|
||||
@Label("Number Of Processed Collectionc")
|
||||
public int numberOfCollectionsProcessed;
|
||||
|
||||
@Label( "Flush time" )
|
||||
@Label("Flush time")
|
||||
public long executionTime;
|
||||
|
||||
@Label( "Auto Flush" )
|
||||
@Label("Auto Flush")
|
||||
public boolean isAutoFlush;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME ;
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public transient long startedAt;
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -15,24 +16,24 @@ import jdk.jfr.Label;
|
|||
import jdk.jfr.Name;
|
||||
import jdk.jfr.StackTrace;
|
||||
|
||||
@Name( JdbcBatchExecutionEvent.NAME )
|
||||
@Label( "JDBC Batch Execution" )
|
||||
@Category( "Hibernate ORM" )
|
||||
@Description( "JDBC Batch Execution" )
|
||||
@Name(JdbcBatchExecutionEvent.NAME)
|
||||
@Label("JDBC Batch Execution")
|
||||
@Category("Hibernate ORM")
|
||||
@Description("JDBC Batch Execution")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class JdbcBatchExecutionEvent extends Event {
|
||||
public class JdbcBatchExecutionEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.JdbcBatchExecution";
|
||||
|
||||
@Label("PreparedStatement SQL")
|
||||
public String sql;
|
||||
|
||||
@Label( "Batch Execution time" )
|
||||
@Label("Batch Execution time")
|
||||
public long executionTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME ;
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public transient long startedAt;
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -15,27 +16,27 @@ import jdk.jfr.Label;
|
|||
import jdk.jfr.Name;
|
||||
import jdk.jfr.StackTrace;
|
||||
|
||||
@Name(JdbcConnectionAcquisitionEvent.NAME )
|
||||
@Label( "JDBC Connection Obtained" )
|
||||
@Category( "Hibernate ORM" )
|
||||
@Description( "JDBC Connection Obtained" )
|
||||
@Name(JdbcConnectionAcquisitionEvent.NAME)
|
||||
@Label("JDBC Connection Obtained")
|
||||
@Category("Hibernate ORM")
|
||||
@Description("JDBC Connection Obtained")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class JdbcConnectionAcquisitionEvent extends Event {
|
||||
public class JdbcConnectionAcquisitionEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.JdbcConnectionAcquisition";
|
||||
|
||||
@Label("Session Identifier" )
|
||||
@Label("Session Identifier")
|
||||
public String sessionIdentifier;
|
||||
|
||||
@Label( "Tenant Identifier" )
|
||||
@Label("Tenant Identifier")
|
||||
public String tenantIdentifier;
|
||||
|
||||
@Label( "Connection Acquisition Time" )
|
||||
@Label("Connection Acquisition Time")
|
||||
public long executionTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME ;
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public transient long startedAt;
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -15,27 +16,27 @@ import jdk.jfr.Label;
|
|||
import jdk.jfr.Name;
|
||||
import jdk.jfr.StackTrace;
|
||||
|
||||
@Name(JdbcConnectionReleaseEvent.NAME )
|
||||
@Label( "JDBC Connection Release" )
|
||||
@Category( "Hibernate ORM" )
|
||||
@Description( "JDBC Connection Released" )
|
||||
@Name(JdbcConnectionReleaseEvent.NAME)
|
||||
@Label("JDBC Connection Release")
|
||||
@Category("Hibernate ORM")
|
||||
@Description("JDBC Connection Released")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class JdbcConnectionReleaseEvent extends Event {
|
||||
public class JdbcConnectionReleaseEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.JdbcConnectionRelease";
|
||||
|
||||
@Label("Session Identifier" )
|
||||
@Label("Session Identifier")
|
||||
public String sessionIdentifier;
|
||||
|
||||
@Label( "Tenant Identifier" )
|
||||
@Label("Tenant Identifier")
|
||||
public String tenantIdentifier;
|
||||
|
||||
@Label( "Connection Release Time" )
|
||||
@Label("Connection Release Time")
|
||||
public long executionTime;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME ;
|
||||
return NAME;
|
||||
}
|
||||
|
||||
public transient long startedAt;
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -21,7 +22,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description("JDBC PreparedStatement Created")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class JdbcPreparedStatementCreationEvent extends Event {
|
||||
public class JdbcPreparedStatementCreationEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.JdbcPreparedStatementCreation";
|
||||
|
||||
@Label("PreparedStatement SQL")
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -21,7 +22,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description( "JDBC PreparedStatement Executed" )
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class JdbcPreparedStatementExecutionEvent extends Event {
|
||||
public class JdbcPreparedStatementExecutionEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.JdbcPreparedStatementExecution";
|
||||
|
||||
@Label( "PreparedStatement SQL" )
|
|
@ -6,24 +6,12 @@
|
|||
*/
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
|
||||
import org.hibernate.cache.spi.Region;
|
||||
import org.hibernate.cache.spi.access.CachedDomainDataAccess;
|
||||
import org.hibernate.engine.spi.EntityEntry;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.DirtyCalculationEvent;
|
||||
import org.hibernate.event.jfr.FlushEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.JdbcConnectionAcquisitionEvent;
|
||||
import org.hibernate.event.jfr.JdbcConnectionReleaseEvent;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.PartialFlushEvent;
|
||||
import org.hibernate.event.jfr.SessionClosedEvent;
|
||||
import org.hibernate.event.jfr.SessionOpenEvent;
|
||||
import org.hibernate.event.spi.EventManager;
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.event.spi.AutoFlushEvent;
|
||||
import org.hibernate.event.spi.EventSource;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
@ -33,10 +21,12 @@ import org.hibernate.stat.internal.StatsHelper;
|
|||
|
||||
import static java.util.concurrent.TimeUnit.NANOSECONDS;
|
||||
|
||||
@AllowNonPortable
|
||||
public class JfrEventManager {
|
||||
|
||||
public static SessionOpenEvent beginSessionOpenEvent() {
|
||||
@AllowNonPortable
|
||||
public class JfrEventManager implements EventManager {
|
||||
|
||||
@Override
|
||||
public SessionOpenEvent beginSessionOpenEvent() {
|
||||
final SessionOpenEvent sessionOpenEvent = new SessionOpenEvent();
|
||||
if ( sessionOpenEvent.isEnabled() ) {
|
||||
sessionOpenEvent.begin();
|
||||
|
@ -44,9 +34,11 @@ public class JfrEventManager {
|
|||
return sessionOpenEvent;
|
||||
}
|
||||
|
||||
public static void completeSessionOpenEvent(
|
||||
SessionOpenEvent sessionOpenEvent,
|
||||
@Override
|
||||
public void completeSessionOpenEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session) {
|
||||
final SessionOpenEvent sessionOpenEvent = (SessionOpenEvent) event;
|
||||
if ( sessionOpenEvent.isEnabled() ) {
|
||||
sessionOpenEvent.end();
|
||||
if ( sessionOpenEvent.shouldCommit() ) {
|
||||
|
@ -56,7 +48,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static SessionClosedEvent beginSessionClosedEvent() {
|
||||
@Override
|
||||
public SessionClosedEvent beginSessionClosedEvent() {
|
||||
final SessionClosedEvent sessionClosedEvent = new SessionClosedEvent();
|
||||
if ( sessionClosedEvent.isEnabled() ) {
|
||||
sessionClosedEvent.begin();
|
||||
|
@ -64,9 +57,11 @@ public class JfrEventManager {
|
|||
return sessionClosedEvent;
|
||||
}
|
||||
|
||||
public static void completeSessionClosedEvent(
|
||||
SessionClosedEvent sessionClosedEvent,
|
||||
@Override
|
||||
public void completeSessionClosedEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session) {
|
||||
final SessionClosedEvent sessionClosedEvent = (SessionClosedEvent) event;
|
||||
if ( sessionClosedEvent.isEnabled() ) {
|
||||
sessionClosedEvent.end();
|
||||
if ( sessionClosedEvent.shouldCommit() ) {
|
||||
|
@ -76,7 +71,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static JdbcConnectionAcquisitionEvent beginJdbcConnectionAcquisitionEvent() {
|
||||
@Override
|
||||
public JdbcConnectionAcquisitionEvent beginJdbcConnectionAcquisitionEvent() {
|
||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = new JdbcConnectionAcquisitionEvent();
|
||||
if ( jdbcConnectionAcquisitionEvent.isEnabled() ) {
|
||||
jdbcConnectionAcquisitionEvent.begin();
|
||||
|
@ -85,10 +81,12 @@ public class JfrEventManager {
|
|||
return jdbcConnectionAcquisitionEvent;
|
||||
}
|
||||
|
||||
public static void completeJdbcConnectionAcquisitionEvent(
|
||||
JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent,
|
||||
@Override
|
||||
public void completeJdbcConnectionAcquisitionEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId) {
|
||||
final JdbcConnectionAcquisitionEvent jdbcConnectionAcquisitionEvent = (JdbcConnectionAcquisitionEvent) event;
|
||||
if ( jdbcConnectionAcquisitionEvent.isEnabled() ) {
|
||||
jdbcConnectionAcquisitionEvent.end();
|
||||
if ( jdbcConnectionAcquisitionEvent.shouldCommit() ) {
|
||||
|
@ -102,7 +100,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static JdbcConnectionReleaseEvent beginJdbcConnectionReleaseEvent() {
|
||||
@Override
|
||||
public JdbcConnectionReleaseEvent beginJdbcConnectionReleaseEvent() {
|
||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = new JdbcConnectionReleaseEvent();
|
||||
if ( jdbcConnectionReleaseEvent.isEnabled() ) {
|
||||
jdbcConnectionReleaseEvent.begin();
|
||||
|
@ -111,10 +110,12 @@ public class JfrEventManager {
|
|||
return jdbcConnectionReleaseEvent;
|
||||
}
|
||||
|
||||
public static void completeJdbcConnectionReleaseEvent(
|
||||
JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent,
|
||||
@Override
|
||||
public void completeJdbcConnectionReleaseEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Object tenantId) {
|
||||
final JdbcConnectionReleaseEvent jdbcConnectionReleaseEvent = (JdbcConnectionReleaseEvent) event;
|
||||
if ( jdbcConnectionReleaseEvent.isEnabled() ) {
|
||||
jdbcConnectionReleaseEvent.end();
|
||||
if ( jdbcConnectionReleaseEvent.shouldCommit() ) {
|
||||
|
@ -128,7 +129,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static JdbcPreparedStatementCreationEvent beginJdbcPreparedStatementCreationEvent() {
|
||||
@Override
|
||||
public JdbcPreparedStatementCreationEvent beginJdbcPreparedStatementCreationEvent() {
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = new JdbcPreparedStatementCreationEvent();
|
||||
if ( jdbcPreparedStatementCreation.isEnabled() ) {
|
||||
jdbcPreparedStatementCreation.begin();
|
||||
|
@ -137,9 +139,11 @@ public class JfrEventManager {
|
|||
return jdbcPreparedStatementCreation;
|
||||
}
|
||||
|
||||
public static void completeJdbcPreparedStatementCreationEvent(
|
||||
JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation,
|
||||
@Override
|
||||
public void completeJdbcPreparedStatementCreationEvent(
|
||||
HibernateEvent event,
|
||||
String preparedStatementSql) {
|
||||
final JdbcPreparedStatementCreationEvent jdbcPreparedStatementCreation = (JdbcPreparedStatementCreationEvent) event;
|
||||
if ( jdbcPreparedStatementCreation.isEnabled() ) {
|
||||
jdbcPreparedStatementCreation.end();
|
||||
if ( jdbcPreparedStatementCreation.shouldCommit() ) {
|
||||
|
@ -150,7 +154,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static JdbcPreparedStatementExecutionEvent beginJdbcPreparedStatementExecutionEvent() {
|
||||
@Override
|
||||
public JdbcPreparedStatementExecutionEvent beginJdbcPreparedStatementExecutionEvent() {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = new JdbcPreparedStatementExecutionEvent();
|
||||
if ( jdbcPreparedStatementExecutionEvent.isEnabled() ) {
|
||||
jdbcPreparedStatementExecutionEvent.begin();
|
||||
|
@ -159,9 +164,11 @@ public class JfrEventManager {
|
|||
return jdbcPreparedStatementExecutionEvent;
|
||||
}
|
||||
|
||||
public static void completeJdbcPreparedStatementExecutionEvent(
|
||||
JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent,
|
||||
@Override
|
||||
public void completeJdbcPreparedStatementExecutionEvent(
|
||||
HibernateEvent event,
|
||||
String preparedStatementSql) {
|
||||
final JdbcPreparedStatementExecutionEvent jdbcPreparedStatementExecutionEvent = (JdbcPreparedStatementExecutionEvent) event;
|
||||
if ( jdbcPreparedStatementExecutionEvent.isEnabled() ) {
|
||||
jdbcPreparedStatementExecutionEvent.end();
|
||||
if ( jdbcPreparedStatementExecutionEvent.shouldCommit() ) {
|
||||
|
@ -173,7 +180,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static JdbcBatchExecutionEvent beginJdbcBatchExecutionEvent() {
|
||||
@Override
|
||||
public JdbcBatchExecutionEvent beginJdbcBatchExecutionEvent() {
|
||||
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = new JdbcBatchExecutionEvent();
|
||||
if ( jdbcBatchExecutionEvent.isEnabled() ) {
|
||||
jdbcBatchExecutionEvent.begin();
|
||||
|
@ -182,9 +190,11 @@ public class JfrEventManager {
|
|||
return jdbcBatchExecutionEvent;
|
||||
}
|
||||
|
||||
public static void completeJdbcBatchExecutionEvent(
|
||||
JdbcBatchExecutionEvent jdbcBatchExecutionEvent,
|
||||
@Override
|
||||
public void completeJdbcBatchExecutionEvent(
|
||||
HibernateEvent event,
|
||||
String statementSql) {
|
||||
final JdbcBatchExecutionEvent jdbcBatchExecutionEvent = (JdbcBatchExecutionEvent) event;
|
||||
if ( jdbcBatchExecutionEvent.isEnabled() ) {
|
||||
jdbcBatchExecutionEvent.end();
|
||||
if ( jdbcBatchExecutionEvent.shouldCommit() ) {
|
||||
|
@ -195,7 +205,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static CachePutEvent beginCachePutEvent() {
|
||||
@Override
|
||||
public HibernateEvent beginCachePutEvent() {
|
||||
final CachePutEvent cachePutEvent = new CachePutEvent();
|
||||
if ( cachePutEvent.isEnabled() ) {
|
||||
cachePutEvent.begin();
|
||||
|
@ -204,12 +215,14 @@ public class JfrEventManager {
|
|||
return cachePutEvent;
|
||||
}
|
||||
|
||||
public static void completeCachePutEvent(
|
||||
CachePutEvent cachePutEvent,
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||
if ( cachePutEvent.isEnabled() ) {
|
||||
cachePutEvent.end();
|
||||
if ( cachePutEvent.shouldCommit() ) {
|
||||
|
@ -223,15 +236,16 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void completeCachePutEvent(
|
||||
CachePutEvent cachePutEvent,
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
completeCachePutEvent(
|
||||
cachePutEvent,
|
||||
event,
|
||||
session,
|
||||
cachedDomainDataAccess,
|
||||
persister,
|
||||
|
@ -241,14 +255,16 @@ public class JfrEventManager {
|
|||
);
|
||||
}
|
||||
|
||||
public static void completeCachePutEvent(
|
||||
CachePutEvent cachePutEvent,
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
EntityPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
boolean isNatualId,
|
||||
CacheActionDescription description) {
|
||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||
if ( cachePutEvent.isEnabled() ) {
|
||||
cachePutEvent.end();
|
||||
if ( cachePutEvent.shouldCommit() ) {
|
||||
|
@ -264,13 +280,15 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void completeCachePutEvent(
|
||||
CachePutEvent cachePutEvent,
|
||||
@Override
|
||||
public void completeCachePutEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
CachedDomainDataAccess cachedDomainDataAccess,
|
||||
CollectionPersister persister,
|
||||
boolean cacheContentChanged,
|
||||
CacheActionDescription description) {
|
||||
final CachePutEvent cachePutEvent = (CachePutEvent) event;
|
||||
if ( cachePutEvent.isEnabled() ) {
|
||||
cachePutEvent.end();
|
||||
if ( cachePutEvent.shouldCommit() ) {
|
||||
|
@ -285,7 +303,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static CacheGetEvent beginCacheGetEvent() {
|
||||
@Override
|
||||
public HibernateEvent beginCacheGetEvent() {
|
||||
final CacheGetEvent cacheGetEvent = new CacheGetEvent();
|
||||
if ( cacheGetEvent.isEnabled() ) {
|
||||
cacheGetEvent.begin();
|
||||
|
@ -294,11 +313,13 @@ public class JfrEventManager {
|
|||
return cacheGetEvent;
|
||||
}
|
||||
|
||||
public static void completeCacheGetEvent(
|
||||
CacheGetEvent cacheGetEvent,
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
boolean hit) {
|
||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||
if ( cacheGetEvent.isEnabled() ) {
|
||||
cacheGetEvent.end();
|
||||
if ( cacheGetEvent.shouldCommit() ) {
|
||||
|
@ -311,13 +332,15 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void completeCacheGetEvent(
|
||||
CacheGetEvent cacheGetEvent,
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
EntityPersister persister,
|
||||
boolean isNaturalKey,
|
||||
boolean hit) {
|
||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||
if ( cacheGetEvent.isEnabled() ) {
|
||||
cacheGetEvent.end();
|
||||
if ( cacheGetEvent.shouldCommit() ) {
|
||||
|
@ -332,12 +355,14 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static void completeCacheGetEvent(
|
||||
CacheGetEvent cacheGetEvent,
|
||||
@Override
|
||||
public void completeCacheGetEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
Region region,
|
||||
CollectionPersister persister,
|
||||
boolean hit) {
|
||||
final CacheGetEvent cacheGetEvent = (CacheGetEvent) event;
|
||||
if ( cacheGetEvent.isEnabled() ) {
|
||||
cacheGetEvent.end();
|
||||
if ( cacheGetEvent.shouldCommit() ) {
|
||||
|
@ -351,7 +376,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static FlushEvent beginFlushEvent() {
|
||||
@Override
|
||||
public FlushEvent beginFlushEvent() {
|
||||
final FlushEvent flushEvent = new FlushEvent();
|
||||
if ( flushEvent.isEnabled() ) {
|
||||
flushEvent.begin();
|
||||
|
@ -360,16 +386,19 @@ public class JfrEventManager {
|
|||
return flushEvent;
|
||||
}
|
||||
|
||||
public static void completeFlushEvent(
|
||||
FlushEvent flushEvent,
|
||||
@Override
|
||||
public void completeFlushEvent(
|
||||
HibernateEvent flushEvent,
|
||||
org.hibernate.event.spi.FlushEvent event) {
|
||||
completeFlushEvent( flushEvent, event, false );
|
||||
}
|
||||
|
||||
public static void completeFlushEvent(
|
||||
FlushEvent flushEvent,
|
||||
@Override
|
||||
public void completeFlushEvent(
|
||||
HibernateEvent hibernateEvent,
|
||||
org.hibernate.event.spi.FlushEvent event,
|
||||
boolean autoFlush) {
|
||||
final FlushEvent flushEvent = (FlushEvent) hibernateEvent;
|
||||
if ( flushEvent.isEnabled() ) {
|
||||
flushEvent.end();
|
||||
if ( flushEvent.shouldCommit() ) {
|
||||
|
@ -384,7 +413,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static PartialFlushEvent beginPartialFlushEvent() {
|
||||
@Override
|
||||
public PartialFlushEvent beginPartialFlushEvent() {
|
||||
final PartialFlushEvent partialFlushEvent = new PartialFlushEvent();
|
||||
if ( partialFlushEvent.isEnabled() ) {
|
||||
partialFlushEvent.startedAt = System.nanoTime();
|
||||
|
@ -393,9 +423,11 @@ public class JfrEventManager {
|
|||
return partialFlushEvent;
|
||||
}
|
||||
|
||||
public static void completePartialFlushEvent(
|
||||
PartialFlushEvent flushEvent,
|
||||
@Override
|
||||
public void completePartialFlushEvent(
|
||||
HibernateEvent hibernateEvent,
|
||||
AutoFlushEvent event) {
|
||||
final PartialFlushEvent flushEvent = (PartialFlushEvent) hibernateEvent;
|
||||
if ( flushEvent.isEnabled() ) {
|
||||
flushEvent.end();
|
||||
if ( flushEvent.shouldCommit() ) {
|
||||
|
@ -410,7 +442,8 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public static DirtyCalculationEvent beginDirtyCalculationEvent() {
|
||||
@Override
|
||||
public DirtyCalculationEvent beginDirtyCalculationEvent() {
|
||||
final DirtyCalculationEvent dirtyCalculationEvent = new DirtyCalculationEvent();
|
||||
if ( dirtyCalculationEvent.isEnabled() ) {
|
||||
dirtyCalculationEvent.startedAt = System.nanoTime();
|
||||
|
@ -419,12 +452,14 @@ public class JfrEventManager {
|
|||
return dirtyCalculationEvent;
|
||||
}
|
||||
|
||||
public static void completeDirtyCalculationEvent(
|
||||
DirtyCalculationEvent dirtyCalculationEvent,
|
||||
@Override
|
||||
public void completeDirtyCalculationEvent(
|
||||
HibernateEvent event,
|
||||
SharedSessionContractImplementor session,
|
||||
EntityPersister persister,
|
||||
EntityEntry entry,
|
||||
int[] dirtyProperties) {
|
||||
final DirtyCalculationEvent dirtyCalculationEvent = (DirtyCalculationEvent) event;
|
||||
if ( dirtyCalculationEvent.isEnabled() ) {
|
||||
dirtyCalculationEvent.end();
|
||||
if ( dirtyCalculationEvent.shouldCommit() ) {
|
||||
|
@ -438,46 +473,18 @@ public class JfrEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public enum CacheActionDescription {
|
||||
ENTITY_INSERT( "Entity Insert" ),
|
||||
ENTITY_AFTER_INSERT( "Entity After Insert" ),
|
||||
ENTITY_UPDATE( "Entity Update" ),
|
||||
ENTITY_LOAD( "Entity Load" ),
|
||||
ENTITY_AFTER_UPDATE( "Entity After Update" ),
|
||||
TIMESTAMP_PRE_INVALIDATE( "Timestamp Pre Invalidate" ),
|
||||
TIMESTAMP_INVALIDATE( "Timestamp Invalidate" ),
|
||||
COLLECTION_INSERT( "Collection Insert" ),
|
||||
QUERY_RESULT( "Query Result" );
|
||||
|
||||
|
||||
private final String text;
|
||||
|
||||
CacheActionDescription(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return text;
|
||||
}
|
||||
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
}
|
||||
|
||||
private static long getExecutionTime(Long startTime) {
|
||||
private long getExecutionTime(Long startTime) {
|
||||
return NANOSECONDS.convert( System.nanoTime() - startTime, NANOSECONDS );
|
||||
}
|
||||
|
||||
private static String getSessionIdentifier(SharedSessionContractImplementor session) {
|
||||
private String getSessionIdentifier(SharedSessionContractImplementor session) {
|
||||
if ( session == null ) {
|
||||
return null;
|
||||
}
|
||||
return session.getSessionIdentifier().toString();
|
||||
}
|
||||
|
||||
private static String getEntityName(EntityPersister persister) {
|
||||
private String getEntityName(EntityPersister persister) {
|
||||
return StatsHelper.INSTANCE.getRootEntityRole( persister ).getFullPath();
|
||||
}
|
||||
}
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -21,7 +22,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description( "PartialFlushEvent Execution" )
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class PartialFlushEvent extends Event {
|
||||
public class PartialFlushEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.PartialFlushEvent";
|
||||
|
||||
@Label( "Session Identifier" )
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -24,7 +25,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description("Hibernate Session closed")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class SessionClosedEvent extends Event {
|
||||
public class SessionClosedEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.SessionClosed";
|
||||
|
||||
@Label("Session Identifier" )
|
|
@ -4,8 +4,9 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.event.jfr;
|
||||
package org.hibernate.event.jfr.internal;
|
||||
|
||||
import org.hibernate.event.spi.HibernateEvent;
|
||||
import org.hibernate.internal.build.AllowNonPortable;
|
||||
|
||||
import jdk.jfr.Category;
|
||||
|
@ -24,7 +25,7 @@ import jdk.jfr.StackTrace;
|
|||
@Description("Hibernate Session opened")
|
||||
@StackTrace(false)
|
||||
@AllowNonPortable
|
||||
public class SessionOpenEvent extends Event {
|
||||
public class SessionOpenEvent extends Event implements HibernateEvent {
|
||||
public static final String NAME = "org.hibernate.orm.SessionOpen";
|
||||
|
||||
@Label("Session Identifier" )
|
|
@ -0,0 +1 @@
|
|||
org.hibernate.event.jfr.internal.JfrEventManager
|
|
@ -1,9 +1,9 @@
|
|||
package org.hibernate.orm.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.engine.spi.Status;
|
||||
import org.hibernate.event.jfr.DirtyCalculationEvent;
|
||||
import org.hibernate.event.jfr.internal.DirtyCalculationEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -1,10 +1,10 @@
|
|||
package org.hibernate.orm.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
|
@ -1,9 +1,10 @@
|
|||
package org.hibernate.orm.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.event.jfr.JdbcConnectionAcquisitionEvent;
|
||||
import org.hibernate.event.jfr.JdbcConnectionReleaseEvent;
|
||||
|
||||
import org.hibernate.event.jfr.internal.JdbcConnectionAcquisitionEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcConnectionReleaseEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -1,10 +1,10 @@
|
|||
package org.hibernate.orm.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.jfr.JdbcPreparedStatementExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcPreparedStatementCreationEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcPreparedStatementExecutionEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -4,12 +4,12 @@
|
|||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
* See the lgpl.txt file in the root directory or http://www.gnu.org/licenses/lgpl-2.1.html.
|
||||
*/
|
||||
package org.hibernate.orm.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.event.jfr.SessionClosedEvent;
|
||||
import org.hibernate.event.jfr.SessionOpenEvent;
|
||||
import org.hibernate.event.jfr.internal.SessionClosedEvent;
|
||||
import org.hibernate.event.jfr.internal.SessionOpenEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -1,10 +1,10 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
|
@ -1,12 +1,12 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
@ -1,12 +1,12 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.annotations.Cache;
|
||||
import org.hibernate.annotations.CacheConcurrencyStrategy;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|||
import org.hibernate.annotations.NaturalId;
|
||||
import org.hibernate.annotations.NaturalIdCache;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CacheGetEvent;
|
||||
import org.hibernate.event.jfr.internal.CacheGetEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.ServiceRegistry;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import org.hibernate.annotations.CacheConcurrencyStrategy;
|
|||
import org.hibernate.annotations.NaturalId;
|
||||
import org.hibernate.annotations.NaturalIdCache;
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
@ -1,10 +1,10 @@
|
|||
package org.hibernate.orm.test.event.jfr.cache;
|
||||
package org.hibernate.event.jfr.cache;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.cfg.AvailableSettings;
|
||||
import org.hibernate.event.jfr.CachePutEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.CachePutEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.JfrEventManager;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
|
@ -1,9 +1,9 @@
|
|||
package org.hibernate.orm.test.event.jfr.flush;
|
||||
package org.hibernate.event.jfr.flush;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.event.jfr.FlushEvent;
|
||||
import org.hibernate.event.jfr.PartialFlushEvent;
|
||||
import org.hibernate.event.jfr.internal.FlushEvent;
|
||||
import org.hibernate.event.jfr.internal.PartialFlushEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -1,8 +1,8 @@
|
|||
package org.hibernate.orm.test.event.jfr.flush;
|
||||
package org.hibernate.event.jfr.flush;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.event.jfr.FlushEvent;
|
||||
import org.hibernate.event.jfr.internal.FlushEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -1,9 +1,9 @@
|
|||
package org.hibernate.orm.test.event.jfr.flush;
|
||||
package org.hibernate.event.jfr.flush;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.hibernate.event.jfr.FlushEvent;
|
||||
import org.hibernate.event.jfr.JdbcBatchExecutionEvent;
|
||||
import org.hibernate.event.jfr.internal.FlushEvent;
|
||||
import org.hibernate.event.jfr.internal.JdbcBatchExecutionEvent;
|
||||
|
||||
import org.hibernate.testing.orm.junit.DomainModel;
|
||||
import org.hibernate.testing.orm.junit.SessionFactory;
|
|
@ -2,4 +2,4 @@
|
|||
* Tests for Hibernate's JFR events. Well the events are roduced on Java 11, the JfrUnit
|
||||
* framewqork used in testing only works on JDK 16+.
|
||||
*/
|
||||
package org.hibernate.test.event.jfr;
|
||||
package org.hibernate.event.jfr;
|
|
@ -0,0 +1,18 @@
|
|||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
#
|
||||
hibernate.dialect @db.dialect@
|
||||
hibernate.connection.driver_class @jdbc.driver@
|
||||
hibernate.connection.url @jdbc.url@
|
||||
hibernate.connection.username @jdbc.user@
|
||||
hibernate.connection.password @jdbc.pass@
|
||||
hibernate.connection.init_sql @connection.init_sql@
|
||||
|
||||
hibernate.connection.pool_size 2
|
||||
|
||||
hibernate.cache.region_prefix hibernate.test
|
||||
|
||||
hibernate.service.allow_crawling=false
|
|
@ -0,0 +1,20 @@
|
|||
#
|
||||
# Hibernate, Relational Persistence for Idiomatic Java
|
||||
#
|
||||
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
||||
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
#
|
||||
appender.stdout.type=Console
|
||||
appender.stdout.name=STDOUT
|
||||
appender.stdout.layout.type=PatternLayout
|
||||
appender.stdout.layout.pattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
|
||||
|
||||
rootLogger.level=info
|
||||
rootLogger.appenderRef.stdout.ref=STDOUT
|
||||
|
||||
logger.test.name=org.hibernate.test
|
||||
logger.test.level=info
|
||||
|
||||
# SQL Logging - HHH-6833
|
||||
logger.sql.name=org.hibernate.SQL
|
||||
logger.sql.level=debug
|
|
@ -319,6 +319,11 @@ include 'hibernate-integrationtest-java-modules'
|
|||
include 'documentation'
|
||||
include 'release'
|
||||
|
||||
// Not all JDK implementations support JFR
|
||||
if ( "OpenJDK Runtime Environment".equals( System.getProperty( "java.runtime.name" ) ) ) {
|
||||
include 'hibernate-jfr'
|
||||
}
|
||||
|
||||
include 'metamodel-generator'
|
||||
project(':metamodel-generator').projectDir = new File(rootProject.projectDir, "tooling/metamodel-generator")
|
||||
project(':metamodel-generator').name = 'hibernate-jpamodelgen'
|
||||
|
@ -332,7 +337,6 @@ project(':hibernate-enhance-maven-plugin').projectDir = new File(rootProject.pro
|
|||
include 'hibernate-ant'
|
||||
project(':hibernate-ant').projectDir = new File(rootProject.projectDir, "tooling/hibernate-ant")
|
||||
|
||||
|
||||
rootProject.children.each { project ->
|
||||
project.buildFileName = "${project.name}.gradle"
|
||||
assert project.projectDir.isDirectory()
|
||||
|
@ -340,4 +344,3 @@ rootProject.children.each { project ->
|
|||
assert project.buildFile.isFile()
|
||||
}
|
||||
include 'hibernate-platform'
|
||||
|
||||
|
|
Loading…
Reference in New Issue