diff --git a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java index 72416bf5f9..636e711112 100644 --- a/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java +++ b/hibernate-core/src/main/java/org/hibernate/event/internal/AbstractFlushingEventListener.java @@ -419,7 +419,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi } else { //otherwise recreate the mapping between the collection and its key - CollectionKey collectionKey = new CollectionKey( + final CollectionKey collectionKey = new CollectionKey( collectionEntry.getLoadedPersister(), collectionEntry.getLoadedKey() ); diff --git a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java index 3305cfe6a0..9e3bc65e4d 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EntityType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EntityType.java @@ -494,8 +494,9 @@ public abstract class EntityType extends AbstractType implements AssociationType if ( type.isEntityType() ) { return ( (EntityType) type ).getIdentifier( propertyValue, session ); } - - return propertyValue; + else { + return propertyValue; + } } } @@ -509,17 +510,18 @@ public abstract class EntityType extends AbstractType implements AssociationType return null; } else { - EntityPersister entityPersister = getAssociatedEntityPersister( sessionFactory ); - Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); + final EntityPersister entityPersister = getAssociatedEntityPersister( sessionFactory ); + final Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName ); // We now have the value of the property-ref we reference. However, // we need to dig a little deeper, as that property might also be // an entity type, in which case we need to resolve its identifier - Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); + final Type type = entityPersister.getPropertyType( uniqueKeyPropertyName ); if ( type.isEntityType() ) { - propertyValue = ( (EntityType) type ).getIdentifier( propertyValue, sessionFactory ); + return ( (EntityType) type ).getIdentifier( propertyValue, sessionFactory ); + } + else { + return propertyValue; } - - return propertyValue; } } @@ -638,11 +640,13 @@ public abstract class EntityType extends AbstractType implements AssociationType return getIdentifierType( factory ); } else { - Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName ); + final Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName ); if ( type.isEntityType() ) { - type = ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory ); + return ( (EntityType) type ).getIdentifierOrUniqueKeyType( factory ); + } + else { + return type; } - return type; } } @@ -687,16 +691,12 @@ public abstract class EntityType extends AbstractType implements AssociationType */ protected final Object resolveIdentifier(Object id, SharedSessionContractImplementor session, Boolean overridingEager) throws HibernateException { - boolean isProxyUnwrapEnabled = unwrapProxy && + final boolean isProxyUnwrapEnabled = unwrapProxy && getAssociatedEntityPersister( session.getFactory() ) .isInstrumented(); - Object proxyOrEntity = session.internalLoad( - getAssociatedEntityName(), - id, - isEager( overridingEager ), - isNullable() - ); + final Object proxyOrEntity = + session.internalLoad( getAssociatedEntityName(), id, isEager( overridingEager ), isNullable() ); final LazyInitializer lazyInitializer = extractLazyInitializer( proxyOrEntity ); if ( lazyInitializer != null ) { @@ -732,14 +732,14 @@ public abstract class EntityType extends AbstractType implements AssociationType Object key, SharedSessionContractImplementor session) throws HibernateException { final SessionFactoryImplementor factory = session.getFactory(); - UniqueKeyLoadable persister = (UniqueKeyLoadable) factory + final UniqueKeyLoadable persister = (UniqueKeyLoadable) factory .getRuntimeMetamodels() .getMappingMetamodel() .getEntityDescriptor( entityName ); //TODO: implement 2nd level caching?! natural id caching ?! proxies?! - EntityUniqueKey euk = new EntityUniqueKey( + final EntityUniqueKey euk = new EntityUniqueKey( entityName, uniqueKeyPropertyName, key,