From 1acc35ca4a820fe8535da960d6f50bd88d95204c Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Fri, 14 Oct 2011 14:13:55 +0100 Subject: [PATCH] HHH-6732 Some logging trace statements are missing guards against unneeded string creation --- .../hibernate/engine/internal/Cascade.java | 33 +++++++---- .../internal/JdbcResourceRegistryImpl.java | 43 ++++++++------ .../jdbc/internal/LogicalConnectionImpl.java | 40 ++++++------- .../org/hibernate/internal/SessionImpl.java | 56 ++++++++++--------- .../entity/AbstractEntityPersister.java | 5 +- .../org/hibernate/tuple/PojoInstantiator.java | 2 +- .../tuple/entity/EntityMetamodel.java | 2 +- 7 files changed, 106 insertions(+), 75 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java index 6c6f0785fb..07f3618391 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/internal/Cascade.java @@ -103,7 +103,7 @@ public final class Cascade { */ public static final int BEFORE_MERGE = 0; - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Cascade.class.getName()); private int cascadeTo; @@ -146,7 +146,9 @@ public final class Cascade { throws HibernateException { if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt - LOG.trace("Processing cascade " + action + " for: " + persister.getEntityName()); + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Processing cascade {0} for: {1}", action, persister.getEntityName() ); + } Type[] types = persister.getPropertyTypes(); CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles(); @@ -181,7 +183,9 @@ public final class Cascade { } } - LOG.trace("Done processing cascade " + action + " for: " + persister.getEntityName()); + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Done processing cascade {0} for: {1}", action, persister.getEntityName() ); + } } } @@ -250,10 +254,10 @@ public final class Cascade { } if ( loadedValue != null ) { final String entityName = entry.getPersister().getEntityName(); - if (LOG.isTraceEnabled()) { + if ( LOG.isTraceEnabled() ) { final Serializable id = entry.getPersister().getIdentifier( loadedValue, eventSource ); final String description = MessageHelper.infoString( entityName, id ); - LOG.trace("Deleting orphaned entity instance: " + description); + LOG.trace( "Deleting orphaned entity instance: " + description ); } eventSource.delete( entityName, loadedValue, false, new HashSet() ); } @@ -396,7 +400,9 @@ public final class Cascade { boolean reallyDoCascade = style.reallyDoCascade(action) && child!=CollectionType.UNFETCHED_COLLECTION; if ( reallyDoCascade ) { - LOG.trace("Cascade " + action + " for collection: " + collectionType.getRole()); + if ( LOG.isTraceEnabled() ) { + LOG.tracev( "Cascade {0} for collection: {1}", action, collectionType.getRole() ); + } Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child); while ( iter.hasNext() ) { @@ -411,7 +417,9 @@ public final class Cascade { ); } - LOG.trace("Done cascade " + action + " for collection: " + collectionType.getRole()); + if ( LOG.isTraceEnabled() ) { + LOG.trace( "Done cascade " + action + " for collection: " + collectionType.getRole() ); + } } final boolean deleteOrphans = style.hasOrphanDelete() && @@ -420,15 +428,18 @@ public final class Cascade { child instanceof PersistentCollection; //a newly instantiated collection can't have orphans if ( deleteOrphans ) { // handle orphaned entities!! - LOG.trace("Deleting orphans for collection: " + collectionType.getRole()); - + if ( LOG.isTraceEnabled() ) { + LOG.trace( "Deleting orphans for collection: " + collectionType.getRole() ); + } // we can do the cast since orphan-delete does not apply to: // 1. newly instantiated collections // 2. arrays (we can't track orphans for detached arrays) final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() ); deleteOrphans( entityName, (PersistentCollection) child ); - LOG.trace("Done deleting orphans for collection: " + collectionType.getRole()); + if ( LOG.isTraceEnabled() ) { + LOG.trace( "Done deleting orphans for collection: " + collectionType.getRole() ); + } } } @@ -452,7 +463,7 @@ public final class Cascade { while ( orphanIter.hasNext() ) { Object orphan = orphanIter.next(); if (orphan!=null) { - LOG.trace("Deleting orphaned entity instance: " + entityName); + LOG.tracev( "Deleting orphaned entity instance: {0}", entityName ); eventSource.delete( entityName, orphan, false, new HashSet() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java index 69117a5400..bb311ac741 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/JdbcResourceRegistryImpl.java @@ -47,8 +47,7 @@ import org.jboss.logging.Logger.Level; */ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, - JdbcResourceRegistryImpl.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, JdbcResourceRegistryImpl.class.getName() ); private final HashMap> xref = new HashMap>(); private final Set unassociatedResultSets = new HashSet(); @@ -61,7 +60,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void register(Statement statement) { - LOG.trace("Registering statement [" + statement + "]"); + LOG.tracev( "Registering statement [{0}]", statement ); if ( xref.containsKey( statement ) ) { throw new HibernateException( "statement already registered with JDBCContainer" ); } @@ -70,7 +69,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { @SuppressWarnings({ "unchecked" }) public void registerLastQuery(Statement statement) { - LOG.trace("Registering last query statement [" + statement + "]"); + LOG.tracev( "Registering last query statement [{0}]", statement ); if ( statement instanceof JdbcWrapper ) { JdbcWrapper wrapper = ( JdbcWrapper ) statement; registerLastQuery( wrapper.getWrappedObject() ); @@ -97,7 +96,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void release(Statement statement) { - LOG.trace("Releasing statement [" + statement + "]"); + LOG.tracev( "Releasing statement [{0}]", statement ); Set resultSets = xref.get( statement ); if ( resultSets != null ) { for ( ResultSet resultSet : resultSets ) { @@ -110,7 +109,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void register(ResultSet resultSet) { - LOG.trace("Registering result set [" + resultSet + "]"); + LOG.tracev( "Registering result set [{0}]", resultSet ); Statement statement; try { statement = resultSet.getStatement(); @@ -119,7 +118,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { throw exceptionHelper.convert( e, "unable to access statement from resultset" ); } if ( statement != null ) { - if (LOG.isEnabled(Level.WARN) && !xref.containsKey(statement)) LOG.unregisteredStatement(); + if ( LOG.isEnabled( Level.WARN ) && !xref.containsKey( statement ) ) { + LOG.unregisteredStatement(); + } Set resultSets = xref.get( statement ); if ( resultSets == null ) { resultSets = new HashSet(); @@ -133,7 +134,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void release(ResultSet resultSet) { - LOG.trace("Releasing result set [" + resultSet + "]"); + LOG.tracev( "Releasing result set [{0}]", resultSet ); Statement statement; try { statement = resultSet.getStatement(); @@ -142,7 +143,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { throw exceptionHelper.convert( e, "unable to access statement from resultset" ); } if ( statement != null ) { - if (LOG.isEnabled(Level.WARN) && !xref.containsKey(statement)) LOG.unregisteredStatement(); + if ( LOG.isEnabled( Level.WARN ) && !xref.containsKey( statement ) ) { + LOG.unregisteredStatement(); + } Set resultSets = xref.get( statement ); if ( resultSets != null ) { resultSets.remove( resultSet ); @@ -153,7 +156,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } else { boolean removed = unassociatedResultSets.remove( resultSet ); - if (!removed) LOG.unregisteredResultSetWithoutStatement(); + if (!removed) LOG.unregisteredResultSetWithoutStatement(); } close( resultSet ); } @@ -163,7 +166,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void releaseResources() { - LOG.trace("Releasing JDBC container resources [" + this + "]"); + LOG.tracev( "Releasing JDBC container resources [{0}]", this ); cleanup(); } @@ -239,13 +242,13 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } public void close() { - LOG.trace("Closing JDBC container [" + this + "]"); + LOG.tracev( "Closing JDBC container [{0}]", this ); cleanup(); } @SuppressWarnings({ "unchecked" }) protected void close(Statement statement) { - LOG.trace("Closing prepared statement [" + statement + "]"); + LOG.tracev( "Closing prepared statement [{0}]", statement ); if ( statement instanceof InvalidatableWrapper ) { InvalidatableWrapper wrapper = ( InvalidatableWrapper ) statement; @@ -267,7 +270,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } catch( SQLException sqle ) { // there was a problem "cleaning" the prepared statement - LOG.debugf("Exception clearing maxRows/queryTimeout [%s]", sqle.getMessage()); + if ( LOG.isDebugEnabled() ) { + LOG.debugf( "Exception clearing maxRows/queryTimeout [%s]", sqle.getMessage() ); + } return; // EARLY EXIT!!! } statement.close(); @@ -276,13 +281,15 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { } } catch( SQLException sqle ) { - LOG.debugf("Unable to release statement [%s]", sqle.getMessage()); + if ( LOG.isDebugEnabled() ) { + LOG.debugf( "Unable to release statement [%s]", sqle.getMessage() ); + } } } @SuppressWarnings({ "unchecked" }) protected void close(ResultSet resultSet) { - LOG.trace("Closing result set [" + resultSet + "]"); + LOG.tracev( "Closing result set [{0}]", resultSet ); if ( resultSet instanceof InvalidatableWrapper ) { InvalidatableWrapper wrapper = (InvalidatableWrapper) resultSet; @@ -294,7 +301,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { resultSet.close(); } catch( SQLException e ) { - LOG.debugf("Unable to release result set [%s]", e.getMessage()); + if ( LOG.isDebugEnabled() ) { + LOG.debugf( "Unable to release result set [%s]", e.getMessage() ); + } } } } diff --git a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java index 30d7f843a7..c75680fa91 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/jdbc/internal/LogicalConnectionImpl.java @@ -56,7 +56,7 @@ import org.jboss.logging.Logger; */ public class LogicalConnectionImpl implements LogicalConnectionImplementor { - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, LogicalConnectionImpl.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, LogicalConnectionImpl.class.getName() ); private transient Connection physicalConnection; private transient Connection shareableConnectionProxy; @@ -117,7 +117,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { } else if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT && ! jdbcServices.getConnectionProvider().supportsAggressiveRelease() ) { - LOG.debugf("Connection provider reports to not support aggressive release; overriding"); + LOG.debugf( "Connection provider reports to not support aggressive release; overriding" ); return ConnectionReleaseMode.AFTER_TRANSACTION; } else { @@ -205,7 +205,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { // no matter what physicalConnection = null; isClosed = true; - LOG.trace("Logical connection closed"); + LOG.trace( "Logical connection closed" ); for ( ConnectionObserver observer : observers ) { observer.logicalConnectionClosed(); } @@ -232,14 +232,14 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { @Override public void afterStatementExecution() { - LOG.trace("Starting after statement execution processing [" + connectionReleaseMode + "]"); + LOG.tracev( "Starting after statement execution processing [{0}]", connectionReleaseMode ); if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT ) { if ( ! releasesEnabled ) { - LOG.debugf("Skipping aggressive release due to manual disabling"); + LOG.debugf( "Skipping aggressive release due to manual disabling" ); return; } if ( jdbcResourceRegistry.hasRegisteredResources() ) { - LOG.debugf("Skipping aggressive release due to registered resources"); + LOG.debugf( "Skipping aggressive release due to registered resources" ); return; } releaseConnection(); @@ -251,7 +251,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT || connectionReleaseMode == ConnectionReleaseMode.AFTER_TRANSACTION ) { if ( jdbcResourceRegistry.hasRegisteredResources() ) { - LOG.forcingContainerResourceCleanup(); + LOG.forcingContainerResourceCleanup(); jdbcResourceRegistry.releaseResources(); } aggressiveRelease(); @@ -260,13 +260,13 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { @Override public void disableReleases() { - LOG.trace("Disabling releases"); + LOG.trace( "Disabling releases" ); releasesEnabled = false; } @Override public void enableReleases() { - LOG.trace("(Re)enabling releases"); + LOG.trace( "(Re)enabling releases" ); releasesEnabled = true; afterStatementExecution(); } @@ -275,9 +275,11 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { * Force aggressive release of the underlying connection. */ public void aggressiveRelease() { - if (isUserSuppliedConnection) LOG.debugf("Cannot aggressively release user-supplied connection; skipping"); + if ( isUserSuppliedConnection ) { + LOG.debugf( "Cannot aggressively release user-supplied connection; skipping" ); + } else { - LOG.debugf("Aggressively releasing JDBC connection"); + LOG.debugf( "Aggressively releasing JDBC connection" ); if ( physicalConnection != null ) { releaseConnection(); } @@ -291,13 +293,13 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { * @throws org.hibernate.JDBCException Indicates problem opening a connection */ private void obtainConnection() throws JDBCException { - LOG.debugf("Obtaining JDBC connection"); + LOG.debugf( "Obtaining JDBC connection" ); try { physicalConnection = jdbcConnectionAccess.obtainConnection(); for ( ConnectionObserver observer : observers ) { observer.physicalConnectionObtained( physicalConnection ); } - LOG.debugf("Obtained JDBC connection"); + LOG.debugf( "Obtained JDBC connection" ); } catch ( SQLException sqle) { throw getJdbcServices().getSqlExceptionHelper().convert( sqle, "Could not open connection" ); @@ -310,15 +312,15 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { * @throws JDBCException Indicates problem closing a connection */ private void releaseConnection() throws JDBCException { - LOG.debugf("Releasing JDBC connection"); + LOG.debugf( "Releasing JDBC connection" ); if ( physicalConnection == null ) { return; } try { - if ( ! physicalConnection.isClosed() ) { + if ( !physicalConnection.isClosed() ) { getJdbcServices().getSqlExceptionHelper().logAndClearWarnings( physicalConnection ); } - if ( ! isUserSuppliedConnection ) { + if ( !isUserSuppliedConnection ) { jdbcConnectionAccess.releaseConnection( physicalConnection ); } } @@ -328,7 +330,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { finally { physicalConnection = null; } - LOG.debugf("Released JDBC connection"); + LOG.debugf( "Released JDBC connection" ); for ( ConnectionObserver observer : observers ) { observer.physicalConnectionReleased(); } @@ -369,7 +371,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { throw new IllegalArgumentException( "cannot reconnect a null user-supplied connection" ); } else if ( suppliedConnection == physicalConnection ) { - LOG.debug("reconnecting the same connection that is already connected; should this connection have been disconnected?"); + LOG.debug( "reconnecting the same connection that is already connected; should this connection have been disconnected?" ); } else if ( physicalConnection != null ) { throw new IllegalArgumentException( @@ -377,7 +379,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor { ); } physicalConnection = suppliedConnection; - LOG.debugf("Reconnected JDBC connection"); + LOG.debugf( "Reconnected JDBC connection" ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java index 95c26068c4..7c8a6b6f76 100644 --- a/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/internal/SessionImpl.java @@ -167,7 +167,7 @@ public final class SessionImpl // a separate class responsible for generating/dispatching events just duplicates most of the Session methods... // passing around separate interceptor, factory, actionQueue, and persistentContext is not manageable... - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionImpl.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, SessionImpl.class.getName()); private transient long timestamp; @@ -242,9 +242,9 @@ public final class SessionImpl loadQueryInfluencers = new LoadQueryInfluencers( factory ); - if (factory.getStatistics().isStatisticsEnabled()) factory.getStatisticsImplementor().openSession(); + if (factory.getStatistics().isStatisticsEnabled()) factory.getStatisticsImplementor().openSession(); - LOG.debugf("Opened session at timestamp: %s", timestamp); + LOG.debugf( "Opened session at timestamp: %s", timestamp ); } @Override @@ -265,7 +265,7 @@ public final class SessionImpl } public Connection close() throws HibernateException { - LOG.trace("Closing session"); + LOG.trace( "Closing session" ); if ( isClosed() ) { throw new SessionException( "Session was already closed" ); } @@ -312,10 +312,10 @@ public final class SessionImpl public void managedFlush() { if ( isClosed() ) { - LOG.trace("Skipping auto-flush due to session closed"); + LOG.trace( "Skipping auto-flush due to session closed" ); return; } - LOG.trace( "Automatically flushing session" ); + LOG.trace( "Automatically flushing session" ); flush(); } @@ -445,7 +445,7 @@ public final class SessionImpl } public void managedClose() { - LOG.trace( "Automatically closing session" ); + LOG.trace( "Automatically closing session" ); close(); } @@ -467,14 +467,14 @@ public final class SessionImpl @Override public Connection disconnect() throws HibernateException { errorIfClosed(); - LOG.debugf( "Disconnecting session" ); + LOG.debugf( "Disconnecting session" ); return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualDisconnect(); } @Override public void reconnect(Connection conn) throws HibernateException { errorIfClosed(); - LOG.debugf("Reconnecting session"); + LOG.debugf( "Reconnecting session" ); checkTransactionSynchStatus(); transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualReconnect( conn ); } @@ -516,7 +516,7 @@ public final class SessionImpl interceptor.beforeTransactionCompletion( hibernateTransaction ); } catch (Throwable t) { - LOG.exceptionInBeforeTransactionCompletionInterceptor(t); + LOG.exceptionInBeforeTransactionCompletionInterceptor( t ); } } @@ -530,7 +530,7 @@ public final class SessionImpl interceptor.afterTransactionCompletion( hibernateTransaction ); } catch (Throwable t) { - LOG.exceptionInAfterTransactionCompletionInterceptor(t); + LOG.exceptionInAfterTransactionCompletionInterceptor( t ); } } if ( autoClear ) { @@ -886,9 +886,9 @@ public final class SessionImpl * Do NOT return a proxy. */ public Object immediateLoad(String entityName, Serializable id) throws HibernateException { - if (LOG.isDebugEnabled()) { + if ( LOG.isDebugEnabled() ) { EntityPersister persister = getFactory().getEntityPersister(entityName); - LOG.debugf("Initializing proxy: %s", MessageHelper.infoString(persister, id, getFactory())); + LOG.debugf( "Initializing proxy: %s", MessageHelper.infoString( persister, id, getFactory() ) ); } LoadEvent event = new LoadEvent(id, entityName, true, this); @@ -1062,16 +1062,16 @@ public final class SessionImpl public boolean isDirty() throws HibernateException { errorIfClosed(); checkTransactionSynchStatus(); - LOG.debugf("Checking session dirtiness"); + LOG.debugf( "Checking session dirtiness" ); if ( actionQueue.areInsertionsOrDeletionsQueued() ) { - LOG.debugf("Session dirty (scheduled updates and insertions)"); + LOG.debugf( "Session dirty (scheduled updates and insertions)" ); return true; } - DirtyCheckEvent event = new DirtyCheckEvent( this ); + DirtyCheckEvent event = new DirtyCheckEvent( this ); for ( DirtyCheckEventListener listener : listeners( EventType.DIRTY_CHECK ) ) { listener.onDirtyCheck( event ); } - return event.isDirty(); + return event.isDirty(); } public void flush() throws HibernateException { @@ -1087,8 +1087,10 @@ public final class SessionImpl public void forceFlush(EntityEntry entityEntry) throws HibernateException { errorIfClosed(); - if (LOG.isDebugEnabled()) LOG.debugf("Flushing to force deletion of re-saved object: %s", - MessageHelper.infoString(entityEntry.getPersister(), entityEntry.getId(), getFactory())); + if ( LOG.isDebugEnabled() ) { + LOG.debugf( "Flushing to force deletion of re-saved object: %s", + MessageHelper.infoString( entityEntry.getPersister(), entityEntry.getId(), getFactory() ) ); + } if ( persistenceContext.getCascadeLevel() > 0 ) { throw new ObjectDeletedException( @@ -1232,7 +1234,7 @@ public final class SessionImpl public void setFlushMode(FlushMode flushMode) { errorIfClosed(); checkTransactionSynchStatus(); - LOG.trace("Setting flush mode to: " + flushMode); + LOG.tracev( "Setting flush mode to: {0}", flushMode ); this.flushMode = flushMode; } @@ -1249,7 +1251,7 @@ public final class SessionImpl public void setCacheMode(CacheMode cacheMode) { errorIfClosed(); checkTransactionSynchStatus(); - LOG.trace("Setting cache mode to: " + cacheMode); + LOG.tracev( "Setting cache mode to: {0}", cacheMode ); this.cacheMode= cacheMode; } @@ -1549,7 +1551,9 @@ public final class SessionImpl errorIfClosed(); checkTransactionSynchStatus(); - LOG.trace("Scroll SQL query: " + customQuery.getSQL()); + if ( LOG.isTraceEnabled() ) { + LOG.trace( "Scroll SQL query: " + customQuery.getSQL() ); + } CustomLoader loader = new CustomLoader( customQuery, getFactory() ); @@ -1570,7 +1574,9 @@ public final class SessionImpl errorIfClosed(); checkTransactionSynchStatus(); - LOG.trace("SQL query: " + customQuery.getSQL()); + if ( LOG.isTraceEnabled() ) { + LOG.trace( "SQL query: " + customQuery.getSQL() ); + } CustomLoader loader = new CustomLoader( customQuery, getFactory() ); @@ -1872,7 +1878,7 @@ public final class SessionImpl * @throws ClassNotFoundException Indicates a class resolution issue */ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { - LOG.trace("Deserializing session"); + LOG.trace( "Deserializing session" ); ois.defaultReadObject(); @@ -1915,7 +1921,7 @@ public final class SessionImpl throw new IllegalStateException( "Cannot serialize a session while connected" ); } - LOG.trace( "Serializing session" ); + LOG.trace( "Serializing session" ); oos.defaultWriteObject(); diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java index 81363df3a6..5a52b411ed 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java @@ -144,6 +144,7 @@ public abstract class AbstractEntityPersister private final boolean isLazyPropertiesCacheable; private final CacheEntryStructure cacheEntryStructure; private final EntityMetamodel entityMetamodel; + private final EntityTuplizer entityTuplizer; // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ private final String[] rootTableKeyColumnNames; @@ -494,6 +495,7 @@ public abstract class AbstractEntityPersister (CacheEntryStructure) new UnstructuredCacheEntry(); this.entityMetamodel = new EntityMetamodel( persistentClass, factory ); + this.entityTuplizer = this.entityMetamodel.getTuplizer(); // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int batch = persistentClass.getBatchSize(); @@ -779,6 +781,7 @@ public abstract class AbstractEntityPersister new StructuredCacheEntry(this) : new UnstructuredCacheEntry(); this.entityMetamodel = new EntityMetamodel( entityBinding, factory ); + this.entityTuplizer = this.entityMetamodel.getTuplizer(); int batch = entityBinding.getBatchSize(); if ( batch == -1 ) { batch = factory.getSettings().getDefaultBatchFetchSize(); @@ -4498,6 +4501,6 @@ public abstract class AbstractEntityPersister @Override public EntityTuplizer getEntityTuplizer() { - return entityMetamodel.getTuplizer(); + return entityTuplizer; } } diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java b/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java index ffcc002293..aeba7c37c2 100755 --- a/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/PojoInstantiator.java @@ -43,7 +43,7 @@ import org.jboss.logging.Logger; */ public class PojoInstantiator implements Instantiator, Serializable { - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, PojoInstantiator.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, PojoInstantiator.class.getName()); private transient Constructor constructor; diff --git a/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java b/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java index e637036897..a02b0a2ba3 100644 --- a/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java +++ b/hibernate-core/src/main/java/org/hibernate/tuple/entity/EntityMetamodel.java @@ -71,7 +71,7 @@ import org.hibernate.type.Type; */ public class EntityMetamodel implements Serializable { - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, EntityMetamodel.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, EntityMetamodel.class.getName()); private static final int NO_VERSION_INDX = -66;