HHH-6732 Some logging trace statements are missing guards against unneeded string creation

This commit is contained in:
Sanne Grinovero 2011-10-14 14:13:55 +01:00
parent 9f1b53fd1e
commit 1acc35ca4a
7 changed files with 106 additions and 75 deletions

View File

@ -103,7 +103,7 @@ public final class Cascade {
*/ */
public static final int BEFORE_MERGE = 0; 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; private int cascadeTo;
@ -146,7 +146,9 @@ public final class Cascade {
throws HibernateException { throws HibernateException {
if ( persister.hasCascades() || action.requiresNoCascadeChecking() ) { // performance opt 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(); Type[] types = persister.getPropertyTypes();
CascadeStyle[] cascadeStyles = persister.getPropertyCascadeStyles(); 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 ) { if ( loadedValue != null ) {
final String entityName = entry.getPersister().getEntityName(); final String entityName = entry.getPersister().getEntityName();
if (LOG.isTraceEnabled()) { if ( LOG.isTraceEnabled() ) {
final Serializable id = entry.getPersister().getIdentifier( loadedValue, eventSource ); final Serializable id = entry.getPersister().getIdentifier( loadedValue, eventSource );
final String description = MessageHelper.infoString( entityName, id ); 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() ); eventSource.delete( entityName, loadedValue, false, new HashSet() );
} }
@ -396,7 +400,9 @@ public final class Cascade {
boolean reallyDoCascade = style.reallyDoCascade(action) && child!=CollectionType.UNFETCHED_COLLECTION; boolean reallyDoCascade = style.reallyDoCascade(action) && child!=CollectionType.UNFETCHED_COLLECTION;
if ( reallyDoCascade ) { 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); Iterator iter = action.getCascadableChildrenIterator(eventSource, collectionType, child);
while ( iter.hasNext() ) { 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() && final boolean deleteOrphans = style.hasOrphanDelete() &&
@ -420,15 +428,18 @@ public final class Cascade {
child instanceof PersistentCollection; //a newly instantiated collection can't have orphans child instanceof PersistentCollection; //a newly instantiated collection can't have orphans
if ( deleteOrphans ) { // handle orphaned entities!! 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: // we can do the cast since orphan-delete does not apply to:
// 1. newly instantiated collections // 1. newly instantiated collections
// 2. arrays (we can't track orphans for detached arrays) // 2. arrays (we can't track orphans for detached arrays)
final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() ); final String entityName = collectionType.getAssociatedEntityName( eventSource.getFactory() );
deleteOrphans( entityName, (PersistentCollection) child ); 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() ) { while ( orphanIter.hasNext() ) {
Object orphan = orphanIter.next(); Object orphan = orphanIter.next();
if (orphan!=null) { 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() ); eventSource.delete( entityName, orphan, false, new HashSet() );
} }
} }

View File

@ -47,8 +47,7 @@ import org.jboss.logging.Logger.Level;
*/ */
public class JdbcResourceRegistryImpl implements JdbcResourceRegistry { public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, JdbcResourceRegistryImpl.class.getName() );
JdbcResourceRegistryImpl.class.getName());
private final HashMap<Statement,Set<ResultSet>> xref = new HashMap<Statement,Set<ResultSet>>(); private final HashMap<Statement,Set<ResultSet>> xref = new HashMap<Statement,Set<ResultSet>>();
private final Set<ResultSet> unassociatedResultSets = new HashSet<ResultSet>(); private final Set<ResultSet> unassociatedResultSets = new HashSet<ResultSet>();
@ -61,7 +60,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void register(Statement statement) { public void register(Statement statement) {
LOG.trace("Registering statement [" + statement + "]"); LOG.tracev( "Registering statement [{0}]", statement );
if ( xref.containsKey( statement ) ) { if ( xref.containsKey( statement ) ) {
throw new HibernateException( "statement already registered with JDBCContainer" ); throw new HibernateException( "statement already registered with JDBCContainer" );
} }
@ -70,7 +69,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
public void registerLastQuery(Statement statement) { public void registerLastQuery(Statement statement) {
LOG.trace("Registering last query statement [" + statement + "]"); LOG.tracev( "Registering last query statement [{0}]", statement );
if ( statement instanceof JdbcWrapper ) { if ( statement instanceof JdbcWrapper ) {
JdbcWrapper<Statement> wrapper = ( JdbcWrapper<Statement> ) statement; JdbcWrapper<Statement> wrapper = ( JdbcWrapper<Statement> ) statement;
registerLastQuery( wrapper.getWrappedObject() ); registerLastQuery( wrapper.getWrappedObject() );
@ -97,7 +96,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void release(Statement statement) { public void release(Statement statement) {
LOG.trace("Releasing statement [" + statement + "]"); LOG.tracev( "Releasing statement [{0}]", statement );
Set<ResultSet> resultSets = xref.get( statement ); Set<ResultSet> resultSets = xref.get( statement );
if ( resultSets != null ) { if ( resultSets != null ) {
for ( ResultSet resultSet : resultSets ) { for ( ResultSet resultSet : resultSets ) {
@ -110,7 +109,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void register(ResultSet resultSet) { public void register(ResultSet resultSet) {
LOG.trace("Registering result set [" + resultSet + "]"); LOG.tracev( "Registering result set [{0}]", resultSet );
Statement statement; Statement statement;
try { try {
statement = resultSet.getStatement(); statement = resultSet.getStatement();
@ -119,7 +118,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
throw exceptionHelper.convert( e, "unable to access statement from resultset" ); throw exceptionHelper.convert( e, "unable to access statement from resultset" );
} }
if ( statement != null ) { if ( statement != null ) {
if (LOG.isEnabled(Level.WARN) && !xref.containsKey(statement)) LOG.unregisteredStatement(); if ( LOG.isEnabled( Level.WARN ) && !xref.containsKey( statement ) ) {
LOG.unregisteredStatement();
}
Set<ResultSet> resultSets = xref.get( statement ); Set<ResultSet> resultSets = xref.get( statement );
if ( resultSets == null ) { if ( resultSets == null ) {
resultSets = new HashSet<ResultSet>(); resultSets = new HashSet<ResultSet>();
@ -133,7 +134,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void release(ResultSet resultSet) { public void release(ResultSet resultSet) {
LOG.trace("Releasing result set [" + resultSet + "]"); LOG.tracev( "Releasing result set [{0}]", resultSet );
Statement statement; Statement statement;
try { try {
statement = resultSet.getStatement(); statement = resultSet.getStatement();
@ -142,7 +143,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
throw exceptionHelper.convert( e, "unable to access statement from resultset" ); throw exceptionHelper.convert( e, "unable to access statement from resultset" );
} }
if ( statement != null ) { if ( statement != null ) {
if (LOG.isEnabled(Level.WARN) && !xref.containsKey(statement)) LOG.unregisteredStatement(); if ( LOG.isEnabled( Level.WARN ) && !xref.containsKey( statement ) ) {
LOG.unregisteredStatement();
}
Set<ResultSet> resultSets = xref.get( statement ); Set<ResultSet> resultSets = xref.get( statement );
if ( resultSets != null ) { if ( resultSets != null ) {
resultSets.remove( resultSet ); resultSets.remove( resultSet );
@ -153,7 +156,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
else { else {
boolean removed = unassociatedResultSets.remove( resultSet ); boolean removed = unassociatedResultSets.remove( resultSet );
if (!removed) LOG.unregisteredResultSetWithoutStatement(); if (!removed) LOG.unregisteredResultSetWithoutStatement();
} }
close( resultSet ); close( resultSet );
} }
@ -163,7 +166,7 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void releaseResources() { public void releaseResources() {
LOG.trace("Releasing JDBC container resources [" + this + "]"); LOG.tracev( "Releasing JDBC container resources [{0}]", this );
cleanup(); cleanup();
} }
@ -239,13 +242,13 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
public void close() { public void close() {
LOG.trace("Closing JDBC container [" + this + "]"); LOG.tracev( "Closing JDBC container [{0}]", this );
cleanup(); cleanup();
} }
@SuppressWarnings({ "unchecked" }) @SuppressWarnings({ "unchecked" })
protected void close(Statement statement) { protected void close(Statement statement) {
LOG.trace("Closing prepared statement [" + statement + "]"); LOG.tracev( "Closing prepared statement [{0}]", statement );
if ( statement instanceof InvalidatableWrapper ) { if ( statement instanceof InvalidatableWrapper ) {
InvalidatableWrapper<Statement> wrapper = ( InvalidatableWrapper<Statement> ) statement; InvalidatableWrapper<Statement> wrapper = ( InvalidatableWrapper<Statement> ) statement;
@ -267,7 +270,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
catch( SQLException sqle ) { catch( SQLException sqle ) {
// there was a problem "cleaning" the prepared statement // 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!!! return; // EARLY EXIT!!!
} }
statement.close(); statement.close();
@ -276,13 +281,15 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
} }
} }
catch( SQLException sqle ) { 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" }) @SuppressWarnings({ "unchecked" })
protected void close(ResultSet resultSet) { protected void close(ResultSet resultSet) {
LOG.trace("Closing result set [" + resultSet + "]"); LOG.tracev( "Closing result set [{0}]", resultSet );
if ( resultSet instanceof InvalidatableWrapper ) { if ( resultSet instanceof InvalidatableWrapper ) {
InvalidatableWrapper<ResultSet> wrapper = (InvalidatableWrapper<ResultSet>) resultSet; InvalidatableWrapper<ResultSet> wrapper = (InvalidatableWrapper<ResultSet>) resultSet;
@ -294,7 +301,9 @@ public class JdbcResourceRegistryImpl implements JdbcResourceRegistry {
resultSet.close(); resultSet.close();
} }
catch( SQLException e ) { 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() );
}
} }
} }
} }

View File

@ -56,7 +56,7 @@ import org.jboss.logging.Logger;
*/ */
public class LogicalConnectionImpl implements LogicalConnectionImplementor { 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 physicalConnection;
private transient Connection shareableConnectionProxy; private transient Connection shareableConnectionProxy;
@ -117,7 +117,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
} }
else if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT && else if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT &&
! jdbcServices.getConnectionProvider().supportsAggressiveRelease() ) { ! 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; return ConnectionReleaseMode.AFTER_TRANSACTION;
} }
else { else {
@ -205,7 +205,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
// no matter what // no matter what
physicalConnection = null; physicalConnection = null;
isClosed = true; isClosed = true;
LOG.trace("Logical connection closed"); LOG.trace( "Logical connection closed" );
for ( ConnectionObserver observer : observers ) { for ( ConnectionObserver observer : observers ) {
observer.logicalConnectionClosed(); observer.logicalConnectionClosed();
} }
@ -232,14 +232,14 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
@Override @Override
public void afterStatementExecution() { 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 ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT ) {
if ( ! releasesEnabled ) { if ( ! releasesEnabled ) {
LOG.debugf("Skipping aggressive release due to manual disabling"); LOG.debugf( "Skipping aggressive release due to manual disabling" );
return; return;
} }
if ( jdbcResourceRegistry.hasRegisteredResources() ) { if ( jdbcResourceRegistry.hasRegisteredResources() ) {
LOG.debugf("Skipping aggressive release due to registered resources"); LOG.debugf( "Skipping aggressive release due to registered resources" );
return; return;
} }
releaseConnection(); releaseConnection();
@ -251,7 +251,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT || if ( connectionReleaseMode == ConnectionReleaseMode.AFTER_STATEMENT ||
connectionReleaseMode == ConnectionReleaseMode.AFTER_TRANSACTION ) { connectionReleaseMode == ConnectionReleaseMode.AFTER_TRANSACTION ) {
if ( jdbcResourceRegistry.hasRegisteredResources() ) { if ( jdbcResourceRegistry.hasRegisteredResources() ) {
LOG.forcingContainerResourceCleanup(); LOG.forcingContainerResourceCleanup();
jdbcResourceRegistry.releaseResources(); jdbcResourceRegistry.releaseResources();
} }
aggressiveRelease(); aggressiveRelease();
@ -260,13 +260,13 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
@Override @Override
public void disableReleases() { public void disableReleases() {
LOG.trace("Disabling releases"); LOG.trace( "Disabling releases" );
releasesEnabled = false; releasesEnabled = false;
} }
@Override @Override
public void enableReleases() { public void enableReleases() {
LOG.trace("(Re)enabling releases"); LOG.trace( "(Re)enabling releases" );
releasesEnabled = true; releasesEnabled = true;
afterStatementExecution(); afterStatementExecution();
} }
@ -275,9 +275,11 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
* Force aggressive release of the underlying connection. * Force aggressive release of the underlying connection.
*/ */
public void aggressiveRelease() { 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 { else {
LOG.debugf("Aggressively releasing JDBC connection"); LOG.debugf( "Aggressively releasing JDBC connection" );
if ( physicalConnection != null ) { if ( physicalConnection != null ) {
releaseConnection(); releaseConnection();
} }
@ -291,13 +293,13 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
* @throws org.hibernate.JDBCException Indicates problem opening a connection * @throws org.hibernate.JDBCException Indicates problem opening a connection
*/ */
private void obtainConnection() throws JDBCException { private void obtainConnection() throws JDBCException {
LOG.debugf("Obtaining JDBC connection"); LOG.debugf( "Obtaining JDBC connection" );
try { try {
physicalConnection = jdbcConnectionAccess.obtainConnection(); physicalConnection = jdbcConnectionAccess.obtainConnection();
for ( ConnectionObserver observer : observers ) { for ( ConnectionObserver observer : observers ) {
observer.physicalConnectionObtained( physicalConnection ); observer.physicalConnectionObtained( physicalConnection );
} }
LOG.debugf("Obtained JDBC connection"); LOG.debugf( "Obtained JDBC connection" );
} }
catch ( SQLException sqle) { catch ( SQLException sqle) {
throw getJdbcServices().getSqlExceptionHelper().convert( sqle, "Could not open connection" ); 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 * @throws JDBCException Indicates problem closing a connection
*/ */
private void releaseConnection() throws JDBCException { private void releaseConnection() throws JDBCException {
LOG.debugf("Releasing JDBC connection"); LOG.debugf( "Releasing JDBC connection" );
if ( physicalConnection == null ) { if ( physicalConnection == null ) {
return; return;
} }
try { try {
if ( ! physicalConnection.isClosed() ) { if ( !physicalConnection.isClosed() ) {
getJdbcServices().getSqlExceptionHelper().logAndClearWarnings( physicalConnection ); getJdbcServices().getSqlExceptionHelper().logAndClearWarnings( physicalConnection );
} }
if ( ! isUserSuppliedConnection ) { if ( !isUserSuppliedConnection ) {
jdbcConnectionAccess.releaseConnection( physicalConnection ); jdbcConnectionAccess.releaseConnection( physicalConnection );
} }
} }
@ -328,7 +330,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
finally { finally {
physicalConnection = null; physicalConnection = null;
} }
LOG.debugf("Released JDBC connection"); LOG.debugf( "Released JDBC connection" );
for ( ConnectionObserver observer : observers ) { for ( ConnectionObserver observer : observers ) {
observer.physicalConnectionReleased(); observer.physicalConnectionReleased();
} }
@ -369,7 +371,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
throw new IllegalArgumentException( "cannot reconnect a null user-supplied connection" ); throw new IllegalArgumentException( "cannot reconnect a null user-supplied connection" );
} }
else if ( suppliedConnection == physicalConnection ) { 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 ) { else if ( physicalConnection != null ) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
@ -377,7 +379,7 @@ public class LogicalConnectionImpl implements LogicalConnectionImplementor {
); );
} }
physicalConnection = suppliedConnection; physicalConnection = suppliedConnection;
LOG.debugf("Reconnected JDBC connection"); LOG.debugf( "Reconnected JDBC connection" );
} }
} }

View File

@ -167,7 +167,7 @@ public final class SessionImpl
// a separate class responsible for generating/dispatching events just duplicates most of the Session methods... // 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... // 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; private transient long timestamp;
@ -242,9 +242,9 @@ public final class SessionImpl
loadQueryInfluencers = new LoadQueryInfluencers( factory ); 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 @Override
@ -265,7 +265,7 @@ public final class SessionImpl
} }
public Connection close() throws HibernateException { public Connection close() throws HibernateException {
LOG.trace("Closing session"); LOG.trace( "Closing session" );
if ( isClosed() ) { if ( isClosed() ) {
throw new SessionException( "Session was already closed" ); throw new SessionException( "Session was already closed" );
} }
@ -312,10 +312,10 @@ public final class SessionImpl
public void managedFlush() { public void managedFlush() {
if ( isClosed() ) { if ( isClosed() ) {
LOG.trace("Skipping auto-flush due to session closed"); LOG.trace( "Skipping auto-flush due to session closed" );
return; return;
} }
LOG.trace( "Automatically flushing session" ); LOG.trace( "Automatically flushing session" );
flush(); flush();
} }
@ -445,7 +445,7 @@ public final class SessionImpl
} }
public void managedClose() { public void managedClose() {
LOG.trace( "Automatically closing session" ); LOG.trace( "Automatically closing session" );
close(); close();
} }
@ -467,14 +467,14 @@ public final class SessionImpl
@Override @Override
public Connection disconnect() throws HibernateException { public Connection disconnect() throws HibernateException {
errorIfClosed(); errorIfClosed();
LOG.debugf( "Disconnecting session" ); LOG.debugf( "Disconnecting session" );
return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualDisconnect(); return transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualDisconnect();
} }
@Override @Override
public void reconnect(Connection conn) throws HibernateException { public void reconnect(Connection conn) throws HibernateException {
errorIfClosed(); errorIfClosed();
LOG.debugf("Reconnecting session"); LOG.debugf( "Reconnecting session" );
checkTransactionSynchStatus(); checkTransactionSynchStatus();
transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualReconnect( conn ); transactionCoordinator.getJdbcCoordinator().getLogicalConnection().manualReconnect( conn );
} }
@ -516,7 +516,7 @@ public final class SessionImpl
interceptor.beforeTransactionCompletion( hibernateTransaction ); interceptor.beforeTransactionCompletion( hibernateTransaction );
} }
catch (Throwable t) { catch (Throwable t) {
LOG.exceptionInBeforeTransactionCompletionInterceptor(t); LOG.exceptionInBeforeTransactionCompletionInterceptor( t );
} }
} }
@ -530,7 +530,7 @@ public final class SessionImpl
interceptor.afterTransactionCompletion( hibernateTransaction ); interceptor.afterTransactionCompletion( hibernateTransaction );
} }
catch (Throwable t) { catch (Throwable t) {
LOG.exceptionInAfterTransactionCompletionInterceptor(t); LOG.exceptionInAfterTransactionCompletionInterceptor( t );
} }
} }
if ( autoClear ) { if ( autoClear ) {
@ -886,9 +886,9 @@ public final class SessionImpl
* Do NOT return a proxy. * Do NOT return a proxy.
*/ */
public Object immediateLoad(String entityName, Serializable id) throws HibernateException { public Object immediateLoad(String entityName, Serializable id) throws HibernateException {
if (LOG.isDebugEnabled()) { if ( LOG.isDebugEnabled() ) {
EntityPersister persister = getFactory().getEntityPersister(entityName); 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); LoadEvent event = new LoadEvent(id, entityName, true, this);
@ -1062,16 +1062,16 @@ public final class SessionImpl
public boolean isDirty() throws HibernateException { public boolean isDirty() throws HibernateException {
errorIfClosed(); errorIfClosed();
checkTransactionSynchStatus(); checkTransactionSynchStatus();
LOG.debugf("Checking session dirtiness"); LOG.debugf( "Checking session dirtiness" );
if ( actionQueue.areInsertionsOrDeletionsQueued() ) { if ( actionQueue.areInsertionsOrDeletionsQueued() ) {
LOG.debugf("Session dirty (scheduled updates and insertions)"); LOG.debugf( "Session dirty (scheduled updates and insertions)" );
return true; return true;
} }
DirtyCheckEvent event = new DirtyCheckEvent( this ); DirtyCheckEvent event = new DirtyCheckEvent( this );
for ( DirtyCheckEventListener listener : listeners( EventType.DIRTY_CHECK ) ) { for ( DirtyCheckEventListener listener : listeners( EventType.DIRTY_CHECK ) ) {
listener.onDirtyCheck( event ); listener.onDirtyCheck( event );
} }
return event.isDirty(); return event.isDirty();
} }
public void flush() throws HibernateException { public void flush() throws HibernateException {
@ -1087,8 +1087,10 @@ public final class SessionImpl
public void forceFlush(EntityEntry entityEntry) throws HibernateException { public void forceFlush(EntityEntry entityEntry) throws HibernateException {
errorIfClosed(); errorIfClosed();
if (LOG.isDebugEnabled()) LOG.debugf("Flushing to force deletion of re-saved object: %s", if ( LOG.isDebugEnabled() ) {
MessageHelper.infoString(entityEntry.getPersister(), entityEntry.getId(), getFactory())); LOG.debugf( "Flushing to force deletion of re-saved object: %s",
MessageHelper.infoString( entityEntry.getPersister(), entityEntry.getId(), getFactory() ) );
}
if ( persistenceContext.getCascadeLevel() > 0 ) { if ( persistenceContext.getCascadeLevel() > 0 ) {
throw new ObjectDeletedException( throw new ObjectDeletedException(
@ -1232,7 +1234,7 @@ public final class SessionImpl
public void setFlushMode(FlushMode flushMode) { public void setFlushMode(FlushMode flushMode) {
errorIfClosed(); errorIfClosed();
checkTransactionSynchStatus(); checkTransactionSynchStatus();
LOG.trace("Setting flush mode to: " + flushMode); LOG.tracev( "Setting flush mode to: {0}", flushMode );
this.flushMode = flushMode; this.flushMode = flushMode;
} }
@ -1249,7 +1251,7 @@ public final class SessionImpl
public void setCacheMode(CacheMode cacheMode) { public void setCacheMode(CacheMode cacheMode) {
errorIfClosed(); errorIfClosed();
checkTransactionSynchStatus(); checkTransactionSynchStatus();
LOG.trace("Setting cache mode to: " + cacheMode); LOG.tracev( "Setting cache mode to: {0}", cacheMode );
this.cacheMode= cacheMode; this.cacheMode= cacheMode;
} }
@ -1549,7 +1551,9 @@ public final class SessionImpl
errorIfClosed(); errorIfClosed();
checkTransactionSynchStatus(); checkTransactionSynchStatus();
LOG.trace("Scroll SQL query: " + customQuery.getSQL()); if ( LOG.isTraceEnabled() ) {
LOG.trace( "Scroll SQL query: " + customQuery.getSQL() );
}
CustomLoader loader = new CustomLoader( customQuery, getFactory() ); CustomLoader loader = new CustomLoader( customQuery, getFactory() );
@ -1570,7 +1574,9 @@ public final class SessionImpl
errorIfClosed(); errorIfClosed();
checkTransactionSynchStatus(); checkTransactionSynchStatus();
LOG.trace("SQL query: " + customQuery.getSQL()); if ( LOG.isTraceEnabled() ) {
LOG.trace( "SQL query: " + customQuery.getSQL() );
}
CustomLoader loader = new CustomLoader( customQuery, getFactory() ); CustomLoader loader = new CustomLoader( customQuery, getFactory() );
@ -1872,7 +1878,7 @@ public final class SessionImpl
* @throws ClassNotFoundException Indicates a class resolution issue * @throws ClassNotFoundException Indicates a class resolution issue
*/ */
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
LOG.trace("Deserializing session"); LOG.trace( "Deserializing session" );
ois.defaultReadObject(); ois.defaultReadObject();
@ -1915,7 +1921,7 @@ public final class SessionImpl
throw new IllegalStateException( "Cannot serialize a session while connected" ); throw new IllegalStateException( "Cannot serialize a session while connected" );
} }
LOG.trace( "Serializing session" ); LOG.trace( "Serializing session" );
oos.defaultWriteObject(); oos.defaultWriteObject();

View File

@ -144,6 +144,7 @@ public abstract class AbstractEntityPersister
private final boolean isLazyPropertiesCacheable; private final boolean isLazyPropertiesCacheable;
private final CacheEntryStructure cacheEntryStructure; private final CacheEntryStructure cacheEntryStructure;
private final EntityMetamodel entityMetamodel; private final EntityMetamodel entityMetamodel;
private final EntityTuplizer entityTuplizer;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
private final String[] rootTableKeyColumnNames; private final String[] rootTableKeyColumnNames;
@ -494,6 +495,7 @@ public abstract class AbstractEntityPersister
(CacheEntryStructure) new UnstructuredCacheEntry(); (CacheEntryStructure) new UnstructuredCacheEntry();
this.entityMetamodel = new EntityMetamodel( persistentClass, factory ); this.entityMetamodel = new EntityMetamodel( persistentClass, factory );
this.entityTuplizer = this.entityMetamodel.getTuplizer();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
int batch = persistentClass.getBatchSize(); int batch = persistentClass.getBatchSize();
@ -779,6 +781,7 @@ public abstract class AbstractEntityPersister
new StructuredCacheEntry(this) : new StructuredCacheEntry(this) :
new UnstructuredCacheEntry(); new UnstructuredCacheEntry();
this.entityMetamodel = new EntityMetamodel( entityBinding, factory ); this.entityMetamodel = new EntityMetamodel( entityBinding, factory );
this.entityTuplizer = this.entityMetamodel.getTuplizer();
int batch = entityBinding.getBatchSize(); int batch = entityBinding.getBatchSize();
if ( batch == -1 ) { if ( batch == -1 ) {
batch = factory.getSettings().getDefaultBatchFetchSize(); batch = factory.getSettings().getDefaultBatchFetchSize();
@ -4498,6 +4501,6 @@ public abstract class AbstractEntityPersister
@Override @Override
public EntityTuplizer getEntityTuplizer() { public EntityTuplizer getEntityTuplizer() {
return entityMetamodel.getTuplizer(); return entityTuplizer;
} }
} }

View File

@ -43,7 +43,7 @@ import org.jboss.logging.Logger;
*/ */
public class PojoInstantiator implements Instantiator, Serializable { 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; private transient Constructor constructor;

View File

@ -71,7 +71,7 @@ import org.hibernate.type.Type;
*/ */
public class EntityMetamodel implements Serializable { 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; private static final int NO_VERSION_INDX = -66;