Removed use of JdbcValuesSourceProcessingState#findInitializer()
This commit is contained in:
parent
0748fff451
commit
ce2dc4720e
|
@ -385,10 +385,6 @@ public abstract class AbstractEntityInitializer extends AbstractFetchParentAcces
|
||||||
// 2) build the EntityKey
|
// 2) build the EntityKey
|
||||||
this.entityKey = new EntityKey( id, concreteDescriptor );
|
this.entityKey = new EntityKey( id, concreteDescriptor );
|
||||||
|
|
||||||
if ( jdbcValuesSourceProcessingState.findInitializer( entityKey ) == null ) {
|
|
||||||
jdbcValuesSourceProcessingState.registerInitializer( entityKey, this );
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3) schedule the EntityKey for batch loading, if possible
|
// 3) schedule the EntityKey for batch loading, if possible
|
||||||
if ( concreteDescriptor.isBatchLoadable() ) {
|
if ( concreteDescriptor.isBatchLoadable() ) {
|
||||||
if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
|
if ( !session.getPersistenceContext().containsEntity( entityKey ) ) {
|
||||||
|
|
|
@ -26,7 +26,6 @@ import org.hibernate.spi.EntityIdentifierNavigablePath;
|
||||||
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.FetchParentAccess;
|
import org.hibernate.sql.results.graph.FetchParentAccess;
|
||||||
import org.hibernate.sql.results.graph.Initializer;
|
|
||||||
import org.hibernate.sql.results.graph.entity.EntityInitializer;
|
import org.hibernate.sql.results.graph.entity.EntityInitializer;
|
||||||
import org.hibernate.sql.results.graph.entity.EntityLoadingLogging;
|
import org.hibernate.sql.results.graph.entity.EntityLoadingLogging;
|
||||||
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
|
import org.hibernate.sql.results.graph.entity.LoadingEntityEntry;
|
||||||
|
@ -89,6 +88,7 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
|
||||||
if ( np instanceof EntityIdentifierNavigablePath
|
if ( np instanceof EntityIdentifierNavigablePath
|
||||||
|| ForeignKeyDescriptor.PART_NAME.equals( np.getLocalName() )
|
|| ForeignKeyDescriptor.PART_NAME.equals( np.getLocalName() )
|
||||||
|| ForeignKeyDescriptor.TARGET_PART_NAME.equals( np.getLocalName() )) {
|
|| ForeignKeyDescriptor.TARGET_PART_NAME.equals( np.getLocalName() )) {
|
||||||
|
|
||||||
initializeInstance( rowProcessingState );
|
initializeInstance( rowProcessingState );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -133,24 +133,6 @@ public class EntitySelectFetchInitializer extends AbstractFetchParentAccess impl
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Initializer initializer = rowProcessingState.getJdbcValuesSourceProcessingState()
|
|
||||||
.findInitializer( entityKey );
|
|
||||||
|
|
||||||
if ( initializer != null ) {
|
|
||||||
if ( EntityLoadingLogging.DEBUG_ENABLED ) {
|
|
||||||
EntityLoadingLogging.ENTITY_LOADING_LOGGER.debugf(
|
|
||||||
"(%s) Found an initializer for entity (%s) : %s",
|
|
||||||
CONCRETE_NAME,
|
|
||||||
toLoggableString( getNavigablePath(), entityIdentifier ),
|
|
||||||
entityIdentifier
|
|
||||||
);
|
|
||||||
}
|
|
||||||
initializer.resolveInstance( rowProcessingState );
|
|
||||||
entityInstance = initializer.getInitializedInstance();
|
|
||||||
isInitialized = true;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final LoadingEntityEntry existingLoadingEntry = session
|
final LoadingEntityEntry existingLoadingEntry = session
|
||||||
.getPersistenceContext()
|
.getPersistenceContext()
|
||||||
.getLoadContexts()
|
.getLoadContexts()
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.hibernate.sql.results.LoadingLogger;
|
||||||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||||
import org.hibernate.sql.results.graph.Initializer;
|
import org.hibernate.sql.results.graph.Initializer;
|
||||||
import org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchInitializer;
|
import org.hibernate.sql.results.graph.entity.internal.EntityDelayedFetchInitializer;
|
||||||
|
import org.hibernate.sql.results.graph.entity.internal.EntitySelectFetchInitializer;
|
||||||
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
|
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingOptions;
|
||||||
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
|
import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
|
||||||
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
import org.hibernate.sql.results.jdbc.spi.RowProcessingState;
|
||||||
|
@ -136,14 +137,14 @@ public class StandardRowReader<T> implements RowReader<T> {
|
||||||
|
|
||||||
for ( int i = 0; i < numberOfInitializers; i++ ) {
|
for ( int i = 0; i < numberOfInitializers; i++ ) {
|
||||||
Initializer initializer = initializers.get( i );
|
Initializer initializer = initializers.get( i );
|
||||||
if ( !( initializer instanceof EntityDelayedFetchInitializer ) ) {
|
if ( !( initializer instanceof EntityDelayedFetchInitializer ) && ! (initializer instanceof EntitySelectFetchInitializer ) ) {
|
||||||
initializer.resolveInstance( rowProcessingState );
|
initializer.resolveInstance( rowProcessingState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( int i = 0; i < numberOfInitializers; i++ ) {
|
for ( int i = 0; i < numberOfInitializers; i++ ) {
|
||||||
Initializer initializer = initializers.get( i );
|
Initializer initializer = initializers.get( i );
|
||||||
if ( initializer instanceof EntityDelayedFetchInitializer ) {
|
if ( initializer instanceof EntityDelayedFetchInitializer || initializer instanceof EntitySelectFetchInitializer ) {
|
||||||
initializer.resolveInstance( rowProcessingState );
|
initializer.resolveInstance( rowProcessingState );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
|
||||||
private final BiConsumer<EntityKey,LoadingEntityEntry> loadingEntityEntryConsumer;
|
private final BiConsumer<EntityKey,LoadingEntityEntry> loadingEntityEntryConsumer;
|
||||||
|
|
||||||
private Map<EntityKey, LoadingEntityEntry> loadingEntityMap;
|
private Map<EntityKey, LoadingEntityEntry> loadingEntityMap;
|
||||||
private Map<EntityKey, Initializer> initializerMap;
|
|
||||||
private Map<EntityUniqueKey, Initializer> initializerByUniquKeyMap;
|
private Map<EntityUniqueKey, Initializer> initializerByUniquKeyMap;
|
||||||
private Map<CollectionKey, LoadingCollectionEntry> loadingCollectionMap;
|
private Map<CollectionKey, LoadingCollectionEntry> loadingCollectionMap;
|
||||||
private List<CollectionInitializer> arrayInitializers;
|
private List<CollectionInitializer> arrayInitializers;
|
||||||
|
@ -114,17 +113,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
|
||||||
loadingEntityMap.put( entityKey, loadingEntry );
|
loadingEntityMap.put( entityKey, loadingEntry );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void registerInitializer(
|
|
||||||
EntityKey entityKey,
|
|
||||||
Initializer initializer) {
|
|
||||||
if ( initializerMap == null ) {
|
|
||||||
initializerMap = new HashMap<>();
|
|
||||||
}
|
|
||||||
initializerMap.put( entityKey, initializer );
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerInitializer(EntityUniqueKey entityKey, Initializer initializer) {
|
public void registerInitializer(EntityUniqueKey entityKey, Initializer initializer) {
|
||||||
if ( initializerByUniquKeyMap == null ) {
|
if ( initializerByUniquKeyMap == null ) {
|
||||||
|
@ -138,11 +126,6 @@ public class JdbcValuesSourceProcessingStateStandardImpl implements JdbcValuesSo
|
||||||
return initializerByUniquKeyMap == null ? null : initializerByUniquKeyMap.get( entityKey );
|
return initializerByUniquKeyMap == null ? null : initializerByUniquKeyMap.get( entityKey );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Initializer findInitializer(EntityKey entityKey) {
|
|
||||||
return initializerMap == null ? null : initializerMap.get( entityKey );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoadingEntityEntry findLoadingEntityLocally(EntityKey entityKey) {
|
public LoadingEntityEntry findLoadingEntityLocally(EntityKey entityKey) {
|
||||||
return loadingEntityMap == null ? null : loadingEntityMap.get( entityKey );
|
return loadingEntityMap == null ? null : loadingEntityMap.get( entityKey );
|
||||||
|
|
|
@ -55,16 +55,10 @@ public interface JdbcValuesSourceProcessingState {
|
||||||
EntityKey entityKey,
|
EntityKey entityKey,
|
||||||
LoadingEntityEntry loadingEntry);
|
LoadingEntityEntry loadingEntry);
|
||||||
|
|
||||||
void registerInitializer(
|
|
||||||
EntityKey entityKey,
|
|
||||||
Initializer initializer);
|
|
||||||
|
|
||||||
void registerInitializer(
|
void registerInitializer(
|
||||||
EntityUniqueKey entityKey,
|
EntityUniqueKey entityKey,
|
||||||
Initializer initializer);
|
Initializer initializer);
|
||||||
|
|
||||||
Initializer findInitializer(EntityKey entityKey);
|
|
||||||
|
|
||||||
Initializer findInitializer(EntityUniqueKey entityKey);
|
Initializer findInitializer(EntityUniqueKey entityKey);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -60,12 +60,6 @@ public class LoadContexts {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Initializer findInitializer(EntityKey key){
|
|
||||||
return jdbcValuesSourceProcessingStateStack.findCurrentFirst(
|
|
||||||
state -> state.findInitializer( key )
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Initializer findInitializer(EntityUniqueKey key){
|
public Initializer findInitializer(EntityUniqueKey key){
|
||||||
return jdbcValuesSourceProcessingStateStack.findCurrentFirst(
|
return jdbcValuesSourceProcessingStateStack.findCurrentFirst(
|
||||||
state -> state.findInitializer( key )
|
state -> state.findInitializer( key )
|
||||||
|
|
Loading…
Reference in New Issue