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