minor code changes (use of final)

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-04 14:04:35 +02:00
parent 1a93a081e1
commit 7b9b495f31
2 changed files with 21 additions and 21 deletions

View File

@ -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()
);

View File

@ -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,