HHH-13828 - Remove EntityPersister's extension of `InFlightEntityMappingType` which is considered an "internal" contract

This commit is contained in:
Steve Ebersole 2020-08-20 14:01:04 -05:00
parent 92aa612f4e
commit fb087dfd72
7 changed files with 22 additions and 54 deletions

View File

@ -79,6 +79,8 @@ public interface EntityMappingType extends ManagedMappingType, EntityValuedModel
return this;
}
void visitQuerySpaces(Consumer<String> querySpaceConsumer);
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Inheritance

View File

@ -62,13 +62,17 @@ public class MappingModelCreationProcess {
*/
private void execute() {
for ( EntityPersister entityPersister : entityPersisterMap.values() ) {
entityPersister.linkWithSuperType( this );
if ( entityPersister instanceof InFlightEntityMappingType ) {
( (InFlightEntityMappingType) entityPersister ).linkWithSuperType( this );
}
}
for ( EntityPersister entityPersister : entityPersisterMap.values() ) {
currentlyProcessingRole = entityPersister.getEntityName();
entityPersister.prepareMappingModel( this );
if ( entityPersister instanceof InFlightEntityMappingType ) {
( (InFlightEntityMappingType) entityPersister ).prepareMappingModel( this );
}
}
MappingModelCreationLogger.LOGGER.debugf( "Starting generic post-init callbacks" );

View File

@ -230,7 +230,8 @@ import org.hibernate.type.spi.TypeConfiguration;
*/
public abstract class AbstractEntityPersister
implements OuterJoinLoadable, Queryable, ClassMetadata, UniqueKeyLoadable,
SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable, org.hibernate.persister.entity.Queryable {
SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable,
org.hibernate.persister.entity.Queryable, InFlightEntityMappingType {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );

View File

@ -9,6 +9,7 @@ package org.hibernate.persister.entity;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
@ -33,7 +34,6 @@ import org.hibernate.internal.TableGroupFilterAliasGenerator;
import org.hibernate.loader.ast.spi.Loadable;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.metamodel.mapping.EntityValuedModelPart;
import org.hibernate.metamodel.mapping.internal.InFlightEntityMappingType;
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
import org.hibernate.persister.walking.spi.EntityDefinition;
@ -77,7 +77,8 @@ import org.hibernate.type.VersionType;
* @see org.hibernate.persister.spi.PersisterFactory
* @see org.hibernate.persister.spi.PersisterClassResolver
*/
public interface EntityPersister extends EntityDefinition, InFlightEntityMappingType, Loadable, RootTableGroupProducer {
public interface EntityPersister
extends EntityMappingType, Loadable, RootTableGroupProducer, EntityDefinition {
/**
* The property name of the "special" identifier property in HQL
@ -89,18 +90,13 @@ public interface EntityPersister extends EntityDefinition, InFlightEntityMapping
* entity persisters before calling {@link #postInstantiate()}.
*
* @deprecated The legacy "walking model" is deprecated in favor of the newer "mapping model".
* This method is no longer called by Hibernate. See {@link #prepareMappingModel} instead
* This method is no longer called by Hibernate. See {@link InFlightEntityMappingType#prepareMappingModel} instead
*/
@Deprecated
void generateEntityDefinition();
@Override
default int getNumberOfFetchables() {
return getNumberOfAttributeMappings();
}
/**
* Finish the initialization of this object. {@link #prepareMappingModel}
* Finish the initialization of this object. {@link InFlightEntityMappingType#prepareMappingModel}
* must be called for all entity persisters before calling this method.
* <p/>
* Called only once per {@link org.hibernate.SessionFactory} lifecycle,
@ -122,18 +118,6 @@ public interface EntityPersister extends EntityDefinition, InFlightEntityMapping
return SqlAliasStemHelper.INSTANCE.generateStemFromEntityName( getEntityName() );
}
@Override
default int getNumberOfAttributeMappings() {
// for backwards-compatibility
return getAttributeMappings().size();
}
@Override
default int getNumberOfDeclaredAttributeMappings() {
// for backwards-compatibility
return getAttributeMappings().size();
}
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// stuff that is persister-centric and/or EntityInfo-centric ~~~~~~~~~~~~~~
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -237,6 +221,13 @@ public interface EntityPersister extends EntityDefinition, InFlightEntityMapping
return (String[]) getQuerySpaces();
}
default void visitQuerySpaces(Consumer<String> querySpaceConsumer) {
final String[] spaces = getSynchronizedQuerySpaces();
for ( int i = 0; i < spaces.length; i++ ) {
querySpaceConsumer.accept( spaces[ i ] );
}
}
/**
* Determine whether this entity supports dynamic proxies.
*

View File

@ -676,16 +676,6 @@ public class PersisterClassProviderTest {
return false;
}
@Override
public void linkWithSuperType(MappingModelCreationProcess creationProcess) {
}
@Override
public void prepareMappingModel(MappingModelCreationProcess creationProcess) {
}
@Override
public EntityIdentifierMapping getIdentifierMapping() {
return null;

View File

@ -698,16 +698,6 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
return false;
}
@Override
public void linkWithSuperType(MappingModelCreationProcess creationProcess) {
}
@Override
public void prepareMappingModel(MappingModelCreationProcess creationProcess) {
}
@Override
public java.util.Collection<AttributeMapping> getAttributeMappings() {
return null;

View File

@ -810,16 +810,6 @@ public class CustomPersister implements EntityPersister {
return false;
}
@Override
public void linkWithSuperType(MappingModelCreationProcess creationProcess) {
}
@Override
public void prepareMappingModel(MappingModelCreationProcess creationProcess) {
}
@Override
public Collection<AttributeMapping> getAttributeMappings() {
return null;