HHH-10366 Check for trace logging before calling log method and unused method parameters
This commit is contained in:
parent
c1cb413c2a
commit
a679528f71
|
@ -116,7 +116,9 @@ public class StandardQueryCache implements QueryCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List cacheable = new ArrayList( result.size() + 1 );
|
final List cacheable = new ArrayList( result.size() + 1 );
|
||||||
logCachedResultDetails( key, null, returnTypes, cacheable );
|
if ( TRACING ) {
|
||||||
|
logCachedResultDetails( key, null, returnTypes, cacheable );
|
||||||
|
}
|
||||||
cacheable.add( session.getTimestamp() );
|
cacheable.add( session.getTimestamp() );
|
||||||
|
|
||||||
final boolean isSingleResult = returnTypes.length == 1;
|
final boolean isSingleResult = returnTypes.length == 1;
|
||||||
|
@ -125,7 +127,9 @@ public class StandardQueryCache implements QueryCache {
|
||||||
? returnTypes[0].disassemble( aResult, session, null )
|
? returnTypes[0].disassemble( aResult, session, null )
|
||||||
: TypeHelper.disassemble( (Object[]) aResult, returnTypes, null, session, null );
|
: TypeHelper.disassemble( (Object[]) aResult, returnTypes, null, session, null );
|
||||||
cacheable.add( cacheItem );
|
cacheable.add( cacheItem );
|
||||||
logCachedResultRowDetails( returnTypes, aResult );
|
if ( TRACING ) {
|
||||||
|
logCachedResultRowDetails( returnTypes, aResult );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -152,8 +156,9 @@ public class StandardQueryCache implements QueryCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
final List cacheable = getCachedResults( key, session );
|
final List cacheable = getCachedResults( key, session );
|
||||||
logCachedResultDetails( key, spaces, returnTypes, cacheable );
|
if ( TRACING ) {
|
||||||
|
logCachedResultDetails( key, spaces, returnTypes, cacheable );
|
||||||
|
}
|
||||||
if ( cacheable == null ) {
|
if ( cacheable == null ) {
|
||||||
if ( DEBUGGING ) {
|
if ( DEBUGGING ) {
|
||||||
LOG.debug( "Query results were not found in cache" );
|
LOG.debug( "Query results were not found in cache" );
|
||||||
|
@ -205,7 +210,9 @@ public class StandardQueryCache implements QueryCache {
|
||||||
result.add(
|
result.add(
|
||||||
TypeHelper.assemble( (Serializable[]) cacheable.get( i ), returnTypes, session, null )
|
TypeHelper.assemble( (Serializable[]) cacheable.get( i ), returnTypes, session, null )
|
||||||
);
|
);
|
||||||
logCachedResultRowDetails( returnTypes, result.get( i - 1 ) );
|
if ( TRACING ) {
|
||||||
|
logCachedResultRowDetails( returnTypes, result.get( i - 1 ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -280,9 +287,6 @@ public class StandardQueryCache implements QueryCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void logCachedResultRowDetails(Type[] returnTypes, Object result) {
|
private static void logCachedResultRowDetails(Type[] returnTypes, Object result) {
|
||||||
if ( !TRACING ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
logCachedResultRowDetails(
|
logCachedResultRowDetails(
|
||||||
returnTypes,
|
returnTypes,
|
||||||
( result instanceof Object[] ? (Object[]) result : new Object[] { result } )
|
( result instanceof Object[] ? (Object[]) result : new Object[] { result } )
|
||||||
|
|
|
@ -613,12 +613,12 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
||||||
if(entry.isReferenceEntry()) {
|
if(entry.isReferenceEntry()) {
|
||||||
if( event.getInstanceToLoad() != null ) {
|
if( event.getInstanceToLoad() != null ) {
|
||||||
throw new HibernateException(
|
throw new HibernateException(
|
||||||
String.format( "Attempt to load entity [%s] from cache using provided object instance, but cache " +
|
"Attempt to load entity [%s] from cache using provided object instance, but cache " +
|
||||||
"is storing references: "+ event.getEntityId()));
|
"is storing references: "+ event.getEntityId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return convertCacheReferenceEntryToEntity( (ReferenceCacheEntryImpl) entry,
|
return convertCacheReferenceEntryToEntity( (ReferenceCacheEntryImpl) entry,
|
||||||
event.getEntityId(), persister, event.getSession(), entityKey, event );
|
event.getSession(), entityKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -666,51 +666,25 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
||||||
|
|
||||||
private Object convertCacheReferenceEntryToEntity(
|
private Object convertCacheReferenceEntryToEntity(
|
||||||
ReferenceCacheEntryImpl referenceCacheEntry,
|
ReferenceCacheEntryImpl referenceCacheEntry,
|
||||||
Serializable entityId,
|
|
||||||
EntityPersister persister,
|
|
||||||
EventSource session,
|
EventSource session,
|
||||||
EntityKey entityKey,
|
EntityKey entityKey) {
|
||||||
LoadEvent loadEvent) {
|
|
||||||
final Object entity = referenceCacheEntry.getReference();
|
final Object entity = referenceCacheEntry.getReference();
|
||||||
|
|
||||||
if ( entity == null ) {
|
if ( entity == null ) {
|
||||||
throw new IllegalStateException(
|
throw new IllegalStateException(
|
||||||
"Reference cache entry contained null : " + entityId);
|
"Reference cache entry contained null : " + referenceCacheEntry.toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
makeEntityCircularReferenceSafe(referenceCacheEntry, entityId, session, entity, entityKey);
|
makeEntityCircularReferenceSafe( referenceCacheEntry, session, entity, entityKey );
|
||||||
//PostLoad is needed for EJB3
|
|
||||||
//but not for reference cached entities??
|
|
||||||
/*
|
|
||||||
EventListenerGroup<PostLoadEventListener> evenListenerGroup = getEvenListenerGroup(session);
|
|
||||||
|
|
||||||
if(!evenListenerGroup.isEmpty()) {
|
|
||||||
postLoad(session, evenListenerGroup.listeners(), entity, entityId, persister, loadEvent);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void postLoad(EventSource session, Iterable<PostLoadEventListener> listeners,
|
|
||||||
Object entity, Serializable entityId, EntityPersister persister, LoadEvent event) {
|
|
||||||
PostLoadEvent postLoadEvent = event.getPostLoadEvent()
|
|
||||||
.setEntity(entity)
|
|
||||||
.setId(entityId)
|
|
||||||
.setPersister(persister);
|
|
||||||
|
|
||||||
for (PostLoadEventListener listener : listeners) {
|
|
||||||
listener.onPostLoad(postLoadEvent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void makeEntityCircularReferenceSafe(ReferenceCacheEntryImpl referenceCacheEntry,
|
private void makeEntityCircularReferenceSafe(ReferenceCacheEntryImpl referenceCacheEntry,
|
||||||
Serializable entityId,
|
|
||||||
EventSource session,
|
EventSource session,
|
||||||
Object entity,
|
Object entity,
|
||||||
EntityKey entityKey) {
|
EntityKey entityKey) {
|
||||||
|
|
||||||
//final EntityPersister subclassPersister = referenceCacheEntry.getSubclassPersister();
|
|
||||||
// make it circular-reference safe
|
// make it circular-reference safe
|
||||||
final StatefulPersistenceContext statefulPersistenceContext = (StatefulPersistenceContext) session.getPersistenceContext();
|
final StatefulPersistenceContext statefulPersistenceContext = (StatefulPersistenceContext) session.getPersistenceContext();
|
||||||
|
|
||||||
|
@ -730,8 +704,6 @@ public class DefaultLoadEventListener extends AbstractLockUpgradeEventListener i
|
||||||
session
|
session
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//subclassPersister.afterInitialize( entity, referenceCacheEntry.areLazyPropertiesUnfetched(), session );
|
|
||||||
statefulPersistenceContext.initializeNonLazyCollections();
|
statefulPersistenceContext.initializeNonLazyCollections();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue