minor code changes (use of final)
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
1a93a081e1
commit
7b9b495f31
|
@ -419,7 +419,7 @@ public abstract class AbstractFlushingEventListener implements JpaBootstrapSensi
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
//otherwise recreate the mapping between the collection and its key
|
//otherwise recreate the mapping between the collection and its key
|
||||||
CollectionKey collectionKey = new CollectionKey(
|
final CollectionKey collectionKey = new CollectionKey(
|
||||||
collectionEntry.getLoadedPersister(),
|
collectionEntry.getLoadedPersister(),
|
||||||
collectionEntry.getLoadedKey()
|
collectionEntry.getLoadedKey()
|
||||||
);
|
);
|
||||||
|
|
|
@ -494,8 +494,9 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
if ( type.isEntityType() ) {
|
if ( type.isEntityType() ) {
|
||||||
return ( (EntityType) type ).getIdentifier( propertyValue, session );
|
return ( (EntityType) type ).getIdentifier( propertyValue, session );
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
return propertyValue;
|
return propertyValue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -509,17 +510,18 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
EntityPersister entityPersister = getAssociatedEntityPersister( sessionFactory );
|
final EntityPersister entityPersister = getAssociatedEntityPersister( sessionFactory );
|
||||||
Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName );
|
final Object propertyValue = entityPersister.getPropertyValue( value, uniqueKeyPropertyName );
|
||||||
// We now have the value of the property-ref we reference. However,
|
// 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
|
// 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
|
// 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() ) {
|
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 );
|
return getIdentifierType( factory );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
final Type type = factory.getReferencedPropertyType( getAssociatedEntityName(), uniqueKeyPropertyName );
|
||||||
if ( type.isEntityType() ) {
|
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 {
|
protected final Object resolveIdentifier(Object id, SharedSessionContractImplementor session, Boolean overridingEager) throws HibernateException {
|
||||||
|
|
||||||
boolean isProxyUnwrapEnabled = unwrapProxy &&
|
final boolean isProxyUnwrapEnabled = unwrapProxy &&
|
||||||
getAssociatedEntityPersister( session.getFactory() )
|
getAssociatedEntityPersister( session.getFactory() )
|
||||||
.isInstrumented();
|
.isInstrumented();
|
||||||
|
|
||||||
Object proxyOrEntity = session.internalLoad(
|
final Object proxyOrEntity =
|
||||||
getAssociatedEntityName(),
|
session.internalLoad( getAssociatedEntityName(), id, isEager( overridingEager ), isNullable() );
|
||||||
id,
|
|
||||||
isEager( overridingEager ),
|
|
||||||
isNullable()
|
|
||||||
);
|
|
||||||
|
|
||||||
final LazyInitializer lazyInitializer = extractLazyInitializer( proxyOrEntity );
|
final LazyInitializer lazyInitializer = extractLazyInitializer( proxyOrEntity );
|
||||||
if ( lazyInitializer != null ) {
|
if ( lazyInitializer != null ) {
|
||||||
|
@ -732,14 +732,14 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
||||||
Object key,
|
Object key,
|
||||||
SharedSessionContractImplementor session) throws HibernateException {
|
SharedSessionContractImplementor session) throws HibernateException {
|
||||||
final SessionFactoryImplementor factory = session.getFactory();
|
final SessionFactoryImplementor factory = session.getFactory();
|
||||||
UniqueKeyLoadable persister = (UniqueKeyLoadable) factory
|
final UniqueKeyLoadable persister = (UniqueKeyLoadable) factory
|
||||||
.getRuntimeMetamodels()
|
.getRuntimeMetamodels()
|
||||||
.getMappingMetamodel()
|
.getMappingMetamodel()
|
||||||
.getEntityDescriptor( entityName );
|
.getEntityDescriptor( entityName );
|
||||||
|
|
||||||
//TODO: implement 2nd level caching?! natural id caching ?! proxies?!
|
//TODO: implement 2nd level caching?! natural id caching ?! proxies?!
|
||||||
|
|
||||||
EntityUniqueKey euk = new EntityUniqueKey(
|
final EntityUniqueKey euk = new EntityUniqueKey(
|
||||||
entityName,
|
entityName,
|
||||||
uniqueKeyPropertyName,
|
uniqueKeyPropertyName,
|
||||||
key,
|
key,
|
||||||
|
|
Loading…
Reference in New Issue