From c668d292572e48952c8b9b79757558039ce862d5 Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Wed, 13 Nov 2013 22:52:38 +0000 Subject: [PATCH] Whitespace and style fixes (only) (cherry picked from commit 0ba7c607780f5b48fc8958cabd1105e235c3dd61) Conflicts: hibernate-core/src/main/java/org/hibernate/loader/Loader.java hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractEntityPersister.java --- .../org/hibernate/engine/spi/EntityEntry.java | 48 +-- .../java/org/hibernate/loader/Loader.java | 307 +++++++++--------- .../entity/AbstractEntityPersister.java | 143 ++++---- .../persister/entity/EntityPersister.java | 2 +- 4 files changed, 247 insertions(+), 253 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityEntry.java b/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityEntry.java index bd7be01a68..f9f07d57a6 100644 --- a/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityEntry.java +++ b/hibernate-core/src/main/java/org/hibernate/engine/spi/EntityEntry.java @@ -109,7 +109,7 @@ public final class EntityEntry implements Serializable { final Status status, final Status previousStatus, final Object[] loadedState, - final Object[] deletedState, + final Object[] deletedState, final Object version, final LockMode lockMode, final boolean existsInDatabase, @@ -206,11 +206,11 @@ public final class EntityEntry implements Serializable { public boolean isBeingReplicated() { return isBeingReplicated; } - + public Object getRowId() { return rowId; } - + /** * Handle updating the internal state of the entry after actually performing * the database update. Specifically we update the snapshot information and @@ -236,8 +236,8 @@ public final class EntityEntry implements Serializable { interceptor.clearDirty(); } } - if( entity instanceof SelfDirtinessTracker) - ((SelfDirtinessTracker) entity).$$_hibernate_clearDirtyAttributes(); + if( entity instanceof SelfDirtinessTracker) + ((SelfDirtinessTracker) entity).$$_hibernate_clearDirtyAttributes(); persistenceContext.getSession() .getFactory() @@ -254,7 +254,7 @@ public final class EntityEntry implements Serializable { status = Status.GONE; existsInDatabase = false; } - + /** * After actually inserting a row, record the fact that the instance exists on the * database (needed for identity-column key generation) @@ -262,7 +262,7 @@ public final class EntityEntry implements Serializable { public void postInsert(Object[] insertedState) { existsInDatabase = true; } - + public boolean isNullifiable(boolean earlyInsert, SessionImplementor session) { return getStatus() == Status.SAVING || ( earlyInsert ? @@ -271,7 +271,7 @@ public final class EntityEntry implements Serializable { .contains( getEntityKey() ) ); } - + public Object getLoadedValue(String propertyName) { if ( loadedState == null ) { return null; @@ -303,24 +303,24 @@ public final class EntityEntry implements Serializable { @SuppressWarnings( {"SimplifiableIfStatement"}) private boolean isUnequivocallyNonDirty(Object entity) { - if(entity instanceof SelfDirtinessTracker) - return ((SelfDirtinessTracker) entity).$$_hibernate_hasDirtyAttributes(); + if(entity instanceof SelfDirtinessTracker) + return ((SelfDirtinessTracker) entity).$$_hibernate_hasDirtyAttributes(); final CustomEntityDirtinessStrategy customEntityDirtinessStrategy = persistenceContext.getSession().getFactory().getCustomEntityDirtinessStrategy(); if ( customEntityDirtinessStrategy.canDirtyCheck( entity, getPersister(), (Session) persistenceContext.getSession() ) ) { return ! customEntityDirtinessStrategy.isDirty( entity, getPersister(), (Session) persistenceContext.getSession() ); } - + if ( getPersister().hasMutableProperties() ) { return false; } - + if ( getPersister().getInstrumentationMetadata().isInstrumented() ) { // the entity must be instrumented (otherwise we cant check dirty flag) and the dirty flag is false return ! getPersister().getInstrumentationMetadata().extractInterceptor( entity ).isDirty(); } - + return false; } @@ -380,7 +380,7 @@ public final class EntityEntry implements Serializable { ); } } - + public String toString() { return "EntityEntry" + MessageHelper.infoString(entityName, id) + @@ -431,27 +431,27 @@ public final class EntityEntry implements Serializable { */ public static EntityEntry deserialize( ObjectInputStream ois, - PersistenceContext persistenceContext) throws IOException, ClassNotFoundException { + PersistenceContext persistenceContext) throws IOException, ClassNotFoundException { String previousStatusString; return new EntityEntry( // this complexity comes from non-flushed changes, should really look at how that reattaches entries ( persistenceContext.getSession() == null ? null : persistenceContext.getSession().getFactory() ), - (String) ois.readObject(), + (String) ois.readObject(), ( Serializable ) ois.readObject(), - EntityMode.parse( (String) ois.readObject() ), + EntityMode.parse( (String) ois.readObject() ), (String) ois.readObject(), Status.valueOf( (String) ois.readObject() ), ( ( previousStatusString = ( String ) ois.readObject() ).length() == 0 ? null : Status.valueOf( previousStatusString ) ), - ( Object[] ) ois.readObject(), - ( Object[] ) ois.readObject(), - ois.readObject(), - LockMode.valueOf( (String) ois.readObject() ), - ois.readBoolean(), - ois.readBoolean(), - ois.readBoolean(), + ( Object[] ) ois.readObject(), + ( Object[] ) ois.readObject(), + ois.readObject(), + LockMode.valueOf( (String) ois.readObject() ), + ois.readBoolean(), + ois.readBoolean(), + ois.readBoolean(), persistenceContext ); } diff --git a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java index 0cf10f9751..e50d804580 100644 --- a/hibernate-core/src/main/java/org/hibernate/loader/Loader.java +++ b/hibernate-core/src/main/java/org/hibernate/loader/Loader.java @@ -112,8 +112,8 @@ import org.hibernate.type.VersionType; */ public abstract class Loader { - protected static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Loader.class.getName()); - protected static final boolean DEBUG_ENABLED = LOG.isDebugEnabled(); + protected static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, Loader.class.getName()); + protected static final boolean DEBUG_ENABLED = LOG.isDebugEnabled(); private final SessionFactoryImplementor factory; private ColumnNameCache columnNameCache; @@ -371,10 +371,10 @@ public abstract class Loader { * @throws HibernateException */ public Object loadSingleRow( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final boolean returnProxies) throws HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final boolean returnProxies) throws HibernateException { final int entitySpan = getEntityPersisters().length; final List hydratedObjects = entitySpan == 0 ? @@ -383,7 +383,7 @@ public abstract class Loader { final Object result; try { result = getRowFromResultSet( - resultSet, + resultSet, session, queryParameters, getLockModes( queryParameters.getLockOptions() ), @@ -395,9 +395,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not read next row of results", - getSQLString() + sqle, + "could not read next row of results", + getSQLString() ); } @@ -412,11 +412,11 @@ public abstract class Loader { } private Object sequentialLoad( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final boolean returnProxies, - final EntityKey keyToRead) throws HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final boolean returnProxies, + final EntityKey keyToRead) throws HibernateException { final int entitySpan = getEntityPersisters().length; final List hydratedObjects = entitySpan == 0 ? @@ -454,9 +454,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not doAfterTransactionCompletion sequential read of results (forward)", - getSQLString() + sqle, + "could not doAfterTransactionCompletion sequential read of results (forward)", + getSQLString() ); } @@ -495,10 +495,10 @@ public abstract class Loader { * @throws HibernateException */ public Object loadSequentialRowsForward( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final boolean returnProxies) throws HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final boolean returnProxies) throws HibernateException { // note that for sequential scrolling, we make the assumption that // the first persister element is the "root entity" @@ -531,9 +531,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not doAfterTransactionCompletion sequential read of results (forward)", - getSQLString() + sqle, + "could not perform sequential read of results (forward)", + getSQLString() ); } } @@ -552,11 +552,11 @@ public abstract class Loader { * @throws HibernateException */ public Object loadSequentialRowsReverse( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final boolean returnProxies, - final boolean isLogicallyAfterLast) throws HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final boolean returnProxies, + final boolean isLogicallyAfterLast) throws HibernateException { // note that for sequential scrolling, we make the assumption that // the first persister element is the "root entity" @@ -656,9 +656,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not doAfterTransactionCompletion sequential read of results (forward)", - getSQLString() + sqle, + "could not doAfterTransactionCompletion sequential read of results (forward)", + getSQLString() ); } } @@ -678,14 +678,14 @@ public abstract class Loader { } private Object getRowFromResultSet( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final LockMode[] lockModesArray, - final EntityKey optionalObjectKey, - final List hydratedObjects, - final EntityKey[] keys, - boolean returnProxies) throws SQLException, HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final LockMode[] lockModesArray, + final EntityKey optionalObjectKey, + final List hydratedObjects, + final EntityKey[] keys, + boolean returnProxies) throws SQLException, HibernateException { return getRowFromResultSet( resultSet, session, @@ -700,15 +700,15 @@ public abstract class Loader { } private Object getRowFromResultSet( - final ResultSet resultSet, - final SessionImplementor session, - final QueryParameters queryParameters, - final LockMode[] lockModesArray, - final EntityKey optionalObjectKey, - final List hydratedObjects, - final EntityKey[] keys, - boolean returnProxies, - ResultTransformer forcedResultTransformer) throws SQLException, HibernateException { + final ResultSet resultSet, + final SessionImplementor session, + final QueryParameters queryParameters, + final LockMode[] lockModesArray, + final EntityKey optionalObjectKey, + final List hydratedObjects, + final EntityKey[] keys, + boolean returnProxies, + ResultTransformer forcedResultTransformer) throws SQLException, HibernateException { final Loadable[] persisters = getEntityPersisters(); final int entitySpan = persisters.length; extractKeysFromResultSet( persisters, queryParameters, resultSet, session, keys, lockModesArray, hydratedObjects ); @@ -717,7 +717,7 @@ public abstract class Loader { // this call is side-effecty Object[] row = getRow( - resultSet, + resultSet, persisters, keys, queryParameters.getOptionalObject(), @@ -944,8 +944,8 @@ public abstract class Loader { int count; for ( count = 0; count < maxRows && rs.next(); count++ ) { - if ( DEBUG_ENABLED ) - LOG.debugf( "Result set row: %s", count ); + if ( DEBUG_ENABLED ) + LOG.debugf( "Result set row: %s", count ); Object result = getRowFromResultSet( rs, session, @@ -964,8 +964,7 @@ public abstract class Loader { } } - if ( LOG.isTraceEnabled() ) - LOG.tracev( "Done processing result set ({0} rows)", count ); + LOG.tracev( "Done processing result set ({0} rows)", count ); initializeEntitiesAndCollections( hydratedObjects, @@ -1108,8 +1107,7 @@ public abstract class Loader { if ( hydratedObjects!=null ) { int hydratedObjectsSize = hydratedObjects.size(); - if ( LOG.isTraceEnabled() ) - LOG.tracev( "Total objects hydrated: {0}", hydratedObjectsSize ); + LOG.tracev( "Total objects hydrated: {0}", hydratedObjectsSize ); for ( int i = 0; i < hydratedObjectsSize; i++ ) { TwoPhaseLoad.initializeEntity( hydratedObjects.get(i), readOnly, session, pre, post ); } @@ -1217,9 +1215,9 @@ public abstract class Loader { * session. */ private void registerNonExists( - final EntityKey[] keys, - final Loadable[] persisters, - final SessionImplementor session) { + final EntityKey[] keys, + final Loadable[] persisters, + final SessionImplementor session) { final int[] owners = getOwners(); if ( owners != null ) { @@ -1279,12 +1277,12 @@ public abstract class Loader { * Read one collection element from the current row of the JDBC result set */ private void readCollectionElement( - final Object optionalOwner, - final Serializable optionalKey, - final CollectionPersister persister, - final CollectionAliases descriptor, - final ResultSet rs, - final SessionImplementor session) + final Object optionalOwner, + final Serializable optionalKey, + final CollectionPersister persister, + final CollectionAliases descriptor, + final ResultSet rs, + final SessionImplementor session) throws HibernateException, SQLException { final PersistenceContext persistenceContext = session.getPersistenceContext(); @@ -1350,9 +1348,9 @@ public abstract class Loader { * no elements (hence no rows in the result set). */ private void handleEmptyCollections( - final Serializable[] keys, - final Object resultSetId, - final SessionImplementor session) { + final Serializable[] keys, + final Object resultSetId, + final SessionImplementor session) { if ( keys != null ) { final boolean debugEnabled = LOG.isDebugEnabled(); @@ -1388,11 +1386,11 @@ public abstract class Loader { * If an id is given, don't bother going to the ResultSet. */ private EntityKey getKeyFromResultSet( - final int i, - final Loadable persister, - final Serializable id, - final ResultSet rs, - final SessionImplementor session) throws HibernateException, SQLException { + final int i, + final Loadable persister, + final Serializable id, + final ResultSet rs, + final SessionImplementor session) throws HibernateException, SQLException { Serializable resultId; @@ -1429,12 +1427,12 @@ public abstract class Loader { * if the version numbers are different */ private void checkVersion( - final int i, - final Loadable persister, - final Serializable id, - final Object entity, - final ResultSet rs, - final SessionImplementor session) + final int i, + final Loadable persister, + final Serializable id, + final Object entity, + final ResultSet rs, + final SessionImplementor session) throws HibernateException, SQLException { Object version = session.getPersistenceContext().getEntry( entity ).getVersion(); @@ -1466,14 +1464,14 @@ public abstract class Loader { * object should be initialized. */ private Object[] getRow( - final ResultSet rs, - final Loadable[] persisters, - final EntityKey[] keys, - final Object optionalObject, - final EntityKey optionalObjectKey, - final LockMode[] lockModes, - final List hydratedObjects, - final SessionImplementor session) + final ResultSet rs, + final Loadable[] persisters, + final EntityKey[] keys, + final Object optionalObject, + final EntityKey optionalObjectKey, + final LockMode[] lockModes, + final List hydratedObjects, + final SessionImplementor session) throws HibernateException, SQLException { final int cols = persisters.length; @@ -1536,12 +1534,12 @@ public abstract class Loader { */ private void instanceAlreadyLoaded( final ResultSet rs, - final int i, - final Loadable persister, - final EntityKey key, - final Object object, - final LockMode lockMode, - final SessionImplementor session) + final int i, + final Loadable persister, + final EntityKey key, + final Object object, + final LockMode requestedLockMode, + final SessionImplementor session) throws HibernateException, SQLException { if ( !persister.isInstance( object ) ) { throw new WrongClassException( @@ -1551,11 +1549,11 @@ public abstract class Loader { ); } - if ( LockMode.NONE != lockMode && upgradeLocks() ) { //no point doing this if NONE was requested + if ( LockMode.NONE != requestedLockMode && upgradeLocks() ) { //no point doing this if NONE was requested final boolean isVersionCheckNeeded = persister.isVersioned() && session.getPersistenceContext().getEntry(object) - .getLockMode().lessThan( lockMode ); + .getLockMode().lessThan( requestedLockMode ); // we don't need to worry about existing version being uninitialized // because this block isn't called by a re-entrant load (re-entrant // loads _always_ have lock mode NONE) @@ -1564,7 +1562,7 @@ public abstract class Loader { checkVersion( i, persister, key.getIdentifier(), object, rs, session ); //we need to upgrade the lock mode to the mode requested session.getPersistenceContext().getEntry(object) - .setLockMode(lockMode); + .setLockMode( requestedLockMode ); } } } @@ -1574,16 +1572,16 @@ public abstract class Loader { * The entity instance is not in the session cache */ private Object instanceNotYetLoaded( - final ResultSet rs, - final int i, - final Loadable persister, - final String rowIdAlias, - final EntityKey key, - final LockMode lockMode, - final EntityKey optionalObjectKey, - final Object optionalObject, - final List hydratedObjects, - final SessionImplementor session) + final ResultSet rs, + final int i, + final Loadable persister, + final String rowIdAlias, + final EntityKey key, + final LockMode lockMode, + final EntityKey optionalObjectKey, + final Object optionalObject, + final List hydratedObjects, + final SessionImplementor session) throws HibernateException, SQLException { final String instanceClass = getInstanceClass( rs, @@ -1656,15 +1654,15 @@ public abstract class Loader { * and pass the hydrates state to the session. */ private void loadFromResultSet( - final ResultSet rs, - final int i, - final Object object, - final String instanceEntityName, - final EntityKey key, - final String rowIdAlias, - final LockMode lockMode, - final Loadable rootPersister, - final SessionImplementor session) + final ResultSet rs, + final int i, + final Object object, + final String instanceEntityName, + final EntityKey key, + final String rowIdAlias, + final LockMode lockMode, + final Loadable rootPersister, + final SessionImplementor session) throws SQLException, HibernateException { final Serializable id = key.getIdentifier(); @@ -1982,10 +1980,10 @@ public abstract class Loader { * @throws org.hibernate.HibernateException Indicates problems delegating binding to the types. */ protected int bindPositionalParameters( - final PreparedStatement statement, - final QueryParameters queryParameters, - final int startIndex, - final SessionImplementor session) throws SQLException, HibernateException { + final PreparedStatement statement, + final QueryParameters queryParameters, + final int startIndex, + final SessionImplementor session) throws SQLException, HibernateException { final Object[] values = queryParameters.getFilteredPositionalParameterValues(); final Type[] types = queryParameters.getFilteredPositionalParameterTypes(); int span = 0; @@ -2053,11 +2051,11 @@ public abstract class Loader { * Execute given PreparedStatement, advance to the first result and return SQL ResultSet. */ protected final ResultSet getResultSet( - final PreparedStatement st, - final RowSelection selection, - final LimitHandler limitHandler, - final boolean autodiscovertypes, - final SessionImplementor session) + final PreparedStatement st, + final RowSelection selection, + final LimitHandler limitHandler, + final boolean autodiscovertypes, + final SessionImplementor session) throws SQLException, HibernateException { try { @@ -2089,8 +2087,7 @@ public abstract class Loader { // potential deadlock issues due to nature of code. if ( session.getFactory().getSettings().isWrapResultSetsEnabled() ) { try { - if ( LOG.isDebugEnabled() ) - LOG.debugf( "Wrapping result set [%s]", rs ); + LOG.debugf( "Wrapping result set [%s]", rs ); return session.getFactory() .getJdbcServices() .getResultSetWrapper().wrap( rs, retreiveColumnNameToIndexCache( rs ) ); @@ -2282,9 +2279,9 @@ public abstract class Loader { * Called by wrappers that batch initialize collections */ public final void loadCollectionBatch( - final SessionImplementor session, - final Serializable[] ids, - final Type type) throws HibernateException { + final SessionImplementor session, + final Serializable[] ids, + final Type type) throws HibernateException { if ( LOG.isDebugEnabled() ) LOG.debugf( "Batch loading collection: %s", @@ -2301,10 +2298,10 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not initialize a collection batch: " + - MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ), - getSQLString() + sqle, + "could not initialize a collection batch: " + + MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ), + getSQLString() ); } @@ -2316,12 +2313,12 @@ public abstract class Loader { * Called by subclasses that batch initialize collections */ protected final void loadCollectionSubselect( - final SessionImplementor session, - final Serializable[] ids, - final Object[] parameterValues, - final Type[] parameterTypes, - final Map namedParameters, - final Type type) throws HibernateException { + final SessionImplementor session, + final Serializable[] ids, + final Object[] parameterValues, + final Type[] parameterTypes, + final Map namedParameters, + final Type type) throws HibernateException { Type[] idTypes = new Type[ids.length]; Arrays.fill( idTypes, type ); @@ -2333,10 +2330,10 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not load collection by subselect: " + - MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ), - getSQLString() + sqle, + "could not load collection by subselect: " + + MessageHelper.collectionInfoString( getCollectionPersisters()[0], ids, getFactory() ), + getSQLString() ); } } @@ -2551,9 +2548,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not execute query", - getSQLString() + sqle, + "could not execute query", + getSQLString() ); } @@ -2603,10 +2600,10 @@ public abstract class Loader { * the ScrollableResults. */ protected ScrollableResults scroll( - final QueryParameters queryParameters, - final Type[] returnTypes, - final HolderInstantiator holderInstantiator, - final SessionImplementor session) throws HibernateException { + final QueryParameters queryParameters, + final Type[] returnTypes, + final HolderInstantiator holderInstantiator, + final SessionImplementor session) throws HibernateException { checkScrollability(); @@ -2656,9 +2653,9 @@ public abstract class Loader { } catch ( SQLException sqle ) { throw factory.getSQLExceptionHelper().convert( - sqle, - "could not execute query using scroll", - getSQLString() + sqle, + "could not execute query using scroll", + getSQLString() ); } @@ -2690,7 +2687,7 @@ public abstract class Loader { } @Override - public String toString() { + public String toString() { return getClass().getName() + '(' + getSQLString() + ')'; } 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 632295b405..4c8c73b79a 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 @@ -37,6 +37,8 @@ import java.util.List; import java.util.Map; import java.util.Set; +import org.jboss.logging.Logger; + import org.hibernate.AssertionFailure; import org.hibernate.EntityMode; import org.hibernate.FetchMode; @@ -44,7 +46,6 @@ import org.hibernate.HibernateException; import org.hibernate.LockMode; import org.hibernate.LockOptions; import org.hibernate.MappingException; -import org.hibernate.PropertyAccessException; import org.hibernate.QueryException; import org.hibernate.StaleObjectStateException; import org.hibernate.StaleStateException; @@ -92,7 +93,6 @@ import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.jdbc.Expectation; import org.hibernate.jdbc.Expectations; import org.hibernate.jdbc.TooManyRowsAffectedException; -import org.hibernate.loader.entity.BatchingEntityLoader; import org.hibernate.loader.entity.BatchingEntityLoaderBuilder; import org.hibernate.loader.entity.CascadeEntityLoader; import org.hibernate.loader.entity.EntityLoader; @@ -130,7 +130,6 @@ import org.hibernate.type.EntityType; import org.hibernate.type.Type; import org.hibernate.type.TypeHelper; import org.hibernate.type.VersionType; -import org.jboss.logging.Logger; /** * Basic functionality for persisting an entity via JDBC @@ -140,10 +139,9 @@ import org.jboss.logging.Logger; */ public abstract class AbstractEntityPersister implements OuterJoinLoadable, Queryable, ClassMetadata, UniqueKeyLoadable, - SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable { + SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable { - private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class, - AbstractEntityPersister.class.getName()); + private static final CoreMessageLogger LOG = Logger.getMessageLogger( CoreMessageLogger.class, AbstractEntityPersister.class.getName() ); public static final String ENTITY_CLASS = "class"; @@ -2145,19 +2143,18 @@ public abstract class AbstractEntityPersister return subclassPropertyNameClosure; } - @Override - public int[] resolveAttributeIndexes(Set properties) { - Iterator iter = properties.iterator(); - int[] fields = new int[properties.size()]; - int counter = 0; - while(iter.hasNext()) { - Integer index = entityMetamodel.getPropertyIndexOrNull(iter.next()); - if(index != null) - fields[counter++] = index; - } - - return fields; - } + @Override + public int[] resolveAttributeIndexes(Set properties) { + Iterator iter = properties.iterator(); + int[] fields = new int[properties.size()]; + int counter = 0; + while(iter.hasNext()) { + Integer index = entityMetamodel.getPropertyIndexOrNull( iter.next() ); + if ( index != null ) + fields[counter++] = index; + } + return fields; + } protected String[] getSubclassPropertySubclassNameClosure() { return subclassPropertySubclassNameClosure; @@ -2631,8 +2628,8 @@ public abstract class AbstractEntityPersister } private boolean checkVersion(final boolean[] includeProperty) { - return includeProperty[ getVersionProperty() ] || - entityMetamodel.getPropertyUpdateGenerationInclusions()[ getVersionProperty() ] != ValueInclusion.NONE; + return includeProperty[ getVersionProperty() ] + || entityMetamodel.getPropertyUpdateGenerationInclusions()[ getVersionProperty() ] != ValueInclusion.NONE; } protected String generateInsertString(boolean[] includeProperty, int j) { @@ -2781,15 +2778,15 @@ public abstract class AbstractEntityPersister */ protected int dehydrate( final Serializable id, - final Object[] fields, - final Object rowId, - final boolean[] includeProperty, - final boolean[][] includeColumns, - final int j, - final PreparedStatement ps, - final SessionImplementor session, - int index, - boolean isUpdate ) throws SQLException, HibernateException { + final Object[] fields, + final Object rowId, + final boolean[] includeProperty, + final boolean[][] includeColumns, + final int j, + final PreparedStatement ps, + final SessionImplementor session, + int index, + boolean isUpdate ) throws SQLException, HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Dehydrating entity: {0}", MessageHelper.infoString( this, id, getFactory() ) ); @@ -2829,7 +2826,7 @@ public abstract class AbstractEntityPersister final Serializable id, final Object rowId, final PreparedStatement ps, - final SessionImplementor session, + final SessionImplementor session, int index ) throws SQLException { if ( rowId != null ) { ps.setObject( index, rowId ); @@ -2848,12 +2845,12 @@ public abstract class AbstractEntityPersister */ public Object[] hydrate( final ResultSet rs, - final Serializable id, - final Object object, - final Loadable rootLoadable, - final String[][] suffixedPropertyColumns, - final boolean allProperties, - final SessionImplementor session) throws SQLException, HibernateException { + final Serializable id, + final Object object, + final Loadable rootLoadable, + final String[][] suffixedPropertyColumns, + final boolean allProperties, + final SessionImplementor session) throws SQLException, HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Hydrating entity: {0}", MessageHelper.infoString( this, id, getFactory() ) ); @@ -2966,10 +2963,10 @@ public abstract class AbstractEntityPersister */ protected Serializable insert( final Object[] fields, - final boolean[] notNull, - String sql, - final Object object, - final SessionImplementor session) throws HibernateException { + final boolean[] notNull, + String sql, + final Object object, + final SessionImplementor session) throws HibernateException { if ( LOG.isTraceEnabled() ) { LOG.tracev( "Inserting entity: {0} (native id)", getEntityName() ); @@ -3017,12 +3014,12 @@ public abstract class AbstractEntityPersister */ protected void insert( final Serializable id, - final Object[] fields, - final boolean[] notNull, - final int j, - final String sql, - final Object object, - final SessionImplementor session) throws HibernateException { + final Object[] fields, + final boolean[] notNull, + final int j, + final String sql, + final Object object, + final SessionImplementor session) throws HibernateException { if ( isInverseTable( j ) ) { return; @@ -3113,15 +3110,15 @@ public abstract class AbstractEntityPersister */ protected void updateOrInsert( final Serializable id, - final Object[] fields, - final Object[] oldFields, - final Object rowId, - final boolean[] includeProperty, - final int j, - final Object oldVersion, - final Object object, - final String sql, - final SessionImplementor session) throws HibernateException { + final Object[] fields, + final Object[] oldFields, + final Object rowId, + final boolean[] includeProperty, + final int j, + final Object oldVersion, + final Object object, + final String sql, + final SessionImplementor session) throws HibernateException { if ( !isInverseTable( j ) ) { @@ -3156,15 +3153,15 @@ public abstract class AbstractEntityPersister protected boolean update( final Serializable id, - final Object[] fields, - final Object[] oldFields, - final Object rowId, - final boolean[] includeProperty, - final int j, - final Object oldVersion, - final Object object, - final String sql, - final SessionImplementor session) throws HibernateException { + final Object[] fields, + final Object[] oldFields, + final Object rowId, + final boolean[] includeProperty, + final int j, + final Object oldVersion, + final Object object, + final String sql, + final SessionImplementor session) throws HibernateException { final Expectation expectation = Expectations.appropriateExpectation( updateResultCheckStyles[j] ); final boolean useBatch = j == 0 && expectation.canBeBatched() && isBatchable(); //note: updates to joined tables can't be batched... @@ -3401,14 +3398,14 @@ public abstract class AbstractEntityPersister */ public void update( final Serializable id, - final Object[] fields, - final int[] dirtyFields, - final boolean hasDirtyCollection, - final Object[] oldFields, - final Object oldVersion, - final Object object, - final Object rowId, - final SessionImplementor session) throws HibernateException { + final Object[] fields, + final int[] dirtyFields, + final boolean hasDirtyCollection, + final Object[] oldFields, + final Object oldVersion, + final Object object, + final Object rowId, + final SessionImplementor session) throws HibernateException { //note: dirtyFields==null means we had no snapshot, and we couldn't get one using select-before-update // oldFields==null just means we had no snapshot to begin with (we might have used select-before-update to get the dirtyFields) diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java index 397a6e55fd..6291a71ce5 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/EntityPersister.java @@ -757,7 +757,7 @@ public interface EntityPersister extends OptimisticCacheSource { public FilterAliasGenerator getFilterAliasGenerator(final String rootAlias); - public int[] resolveAttributeIndexes(Set properties); + public int[] resolveAttributeIndexes(Set properties); public boolean canUseReferenceCacheEntries(); }