EntityValuedFetchable add isOptional and isUnwrapproxy methods

This commit is contained in:
Andrea Boriero 2021-10-18 19:17:58 +02:00
parent 6ffcee44a6
commit 6ddf3530fa
4 changed files with 24 additions and 3 deletions

View File

@ -63,7 +63,6 @@ public class EntityCollectionPart
MappingModelCreationProcess creationProcess) { MappingModelCreationProcess creationProcess) {
this.navigableRole = collectionDescriptor.getNavigableRole().appendContainer( nature.getName() ); this.navigableRole = collectionDescriptor.getNavigableRole().appendContainer( nature.getName() );
this.collectionDescriptor = collectionDescriptor; this.collectionDescriptor = collectionDescriptor;
this.nature = nature; this.nature = nature;
this.entityMappingType = entityMappingType; this.entityMappingType = entityMappingType;
} }
@ -163,6 +162,16 @@ public class EntityCollectionPart
return new EntityFetchJoinedImpl( fetchParent, this, tableGroup, selected, fetchablePath, creationState ); return new EntityFetchJoinedImpl( fetchParent, this, tableGroup, selected, fetchablePath, creationState );
} }
@Override
public boolean isOptional() {
return false;
}
@Override
public boolean isUnwrapProxy() {
return false;
}
@Override @Override
public <T> DomainResult<T> createDomainResult( public <T> DomainResult<T> createDomainResult(
NavigablePath navigablePath, NavigablePath navigablePath,

View File

@ -1050,6 +1050,7 @@ public class ToOneAttributeMapping
return isNullable; return isNullable;
} }
@Override
public boolean isOptional(){ public boolean isOptional(){
return isOptional; return isOptional;
} }
@ -1062,6 +1063,7 @@ public class ToOneAttributeMapping
return isIgnoreNotFound; return isIgnoreNotFound;
} }
@Override
public boolean isUnwrapProxy() { public boolean isUnwrapProxy() {
return unwrapProxy; return unwrapProxy;
} }

View File

@ -25,4 +25,8 @@ public interface EntityValuedFetchable extends Fetchable, EntityValuedModelPart
boolean selected, boolean selected,
String resultVariable, String resultVariable,
DomainResultCreationState creationState); DomainResultCreationState creationState);
boolean isOptional();
boolean isUnwrapProxy();
} }

View File

@ -8,11 +8,15 @@ package org.hibernate.sql.results.graph.entity.internal;
import java.util.function.Consumer; import java.util.function.Consumer;
import org.hibernate.LockMode;
import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NotYetImplementedFor6Exception;
import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer; import org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer;
import org.hibernate.engine.spi.EntityKey; import org.hibernate.engine.spi.EntityKey;
import org.hibernate.engine.spi.PersistenceContext; import org.hibernate.engine.spi.PersistenceContext;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.event.spi.EventSource;
import org.hibernate.internal.log.LoggingHelper; import org.hibernate.internal.log.LoggingHelper;
import org.hibernate.loader.entity.CacheEntityLoaderHelper;
import org.hibernate.metamodel.mapping.ModelPart; import org.hibernate.metamodel.mapping.ModelPart;
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping; import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
@ -21,8 +25,10 @@ import org.hibernate.query.NavigablePath;
import org.hibernate.sql.results.graph.AbstractFetchParentAccess; import org.hibernate.sql.results.graph.AbstractFetchParentAccess;
import org.hibernate.sql.results.graph.DomainResultAssembler; import org.hibernate.sql.results.graph.DomainResultAssembler;
import org.hibernate.sql.results.graph.entity.EntityInitializer; import org.hibernate.sql.results.graph.entity.EntityInitializer;
import org.hibernate.sql.results.graph.entity.EntityValuedFetchable;
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry; import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
import org.hibernate.sql.results.jdbc.spi.RowProcessingState; import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
import org.hibernate.stat.spi.StatisticsImplementor;
/** /**
* @author Andrea Boriero * @author Andrea Boriero
@ -31,7 +37,7 @@ import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess implements EntityInitializer { public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess implements EntityInitializer {
private final NavigablePath navigablePath; private final NavigablePath navigablePath;
private final ToOneAttributeMapping referencedModelPart; private final EntityValuedFetchable referencedModelPart;
private final DomainResultAssembler identifierAssembler; private final DomainResultAssembler identifierAssembler;
private Object entityInstance; private Object entityInstance;
@ -39,7 +45,7 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
public EntityDelayedFetchInitializer( public EntityDelayedFetchInitializer(
NavigablePath fetchedNavigable, NavigablePath fetchedNavigable,
ToOneAttributeMapping referencedModelPart, EntityValuedFetchable referencedModelPart,
DomainResultAssembler identifierAssembler) { DomainResultAssembler identifierAssembler) {
this.navigablePath = fetchedNavigable; this.navigablePath = fetchedNavigable;
this.referencedModelPart = referencedModelPart; this.referencedModelPart = referencedModelPart;