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