remove SQLLoadable and SQLLoadableCollection

and some obsolete related code

Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
Gavin King 2024-06-01 11:19:14 +02:00 committed by Steve Ebersole
parent efd2e90f5f
commit 4013246d75
12 changed files with 41 additions and 192 deletions

View File

@ -81,7 +81,6 @@ import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
import org.hibernate.persister.collection.AbstractCollectionPersister;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Joinable;
import org.hibernate.property.access.internal.ChainedPropertyAccessImpl;
@ -565,8 +564,7 @@ public class MappingModelCreationHelper {
indexDescriptor = null;
assert collectionDescriptor instanceof SQLLoadableCollection;
final SQLLoadableCollection loadableCollection = (SQLLoadableCollection) collectionDescriptor;
final QueryableCollection loadableCollection = (QueryableCollection) collectionDescriptor;
final String identifierColumnName = loadableCollection.getIdentifierColumnName();
assert identifierColumnName != null;

View File

@ -26,7 +26,6 @@ import org.hibernate.Internal;
import org.hibernate.LockOptions;
import org.hibernate.MappingException;
import org.hibernate.QueryException;
import org.hibernate.Remove;
import org.hibernate.TransientObjectException;
import org.hibernate.annotations.CacheLayout;
import org.hibernate.boot.spi.MetadataImplementor;
@ -871,24 +870,6 @@ public abstract class AbstractCollectionPersister
protected abstract RowMutationOperations getRowMutationOperations();
protected abstract RemoveCoordinator getRemoveCoordinator();
@Override
public String getSQLOrderByString(String alias) {
if ( hasOrdering() ) {
throw new UnsupportedOperationException();
}
return "";
}
@Override
public String getManyToManyOrderByString(String alias) {
if ( hasManyToManyOrdering() ) {
throw new UnsupportedOperationException();
}
return "";
}
@Override
public FetchMode getFetchMode() {
return fetchMode;

View File

@ -10,9 +10,5 @@ package org.hibernate.persister.collection;
* @deprecated Just used to singly extend all the deprecated collection persister roles
*/
@Deprecated
public interface DeprecatedCollectionStuff extends SQLLoadableCollection {
@Override
default String getRole() {
return SQLLoadableCollection.super.getRole();
}
public interface DeprecatedCollectionStuff extends QueryableCollection {
}

View File

@ -53,18 +53,10 @@ public interface QueryableCollection extends PropertyMapping, Joinable, Collecti
* key columns in the case of a one-to-many association)
*/
String[] getElementColumnNames();
/**
* Get the order by SQL
*/
String getSQLOrderByString(String alias);
/**
* Get the order-by to be applied at the target table of a many to many
*
* @param alias The alias for the many-to-many target table
* @return appropriate order-by fragment or empty string.
*/
String getManyToManyOrderByString(String alias);
String getIdentifierColumnName();
String[] getCollectionPropertyColumnAliases(String propertyName, String string);
/**
* Does this collection role have a where clause filter?
@ -81,5 +73,4 @@ public interface QueryableCollection extends PropertyMapping, Joinable, Collecti
* Should we load this collection role by outerjoining?
*/
FetchMode getFetchMode();
}

View File

@ -1,17 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.collection;
@Deprecated( since = "6" )
public interface SQLLoadableCollection extends QueryableCollection {
String[] getCollectionPropertyColumnAliases(String propertyName, String string);
String getIdentifierColumnName();
}

View File

@ -78,7 +78,6 @@ import org.hibernate.engine.internal.CacheHelper;
import org.hibernate.engine.internal.ImmutableEntityEntryFactory;
import org.hibernate.engine.internal.MutableEntityEntryFactory;
import org.hibernate.engine.internal.StatefulPersistenceContext;
import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.engine.profile.internal.FetchProfileAffectee;
import org.hibernate.engine.spi.CachedNaturalIdValueSource;
@ -237,7 +236,6 @@ import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategyProvide
import org.hibernate.service.ServiceRegistry;
import org.hibernate.spi.NavigablePath;
import org.hibernate.sql.Alias;
import org.hibernate.sql.Delete;
import org.hibernate.sql.InFragment;
import org.hibernate.sql.SimpleSelect;
import org.hibernate.sql.Template;
@ -308,7 +306,6 @@ import static org.hibernate.engine.internal.ManagedTypeHelper.isPersistentAttrib
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfManagedEntity;
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfPersistentAttributeInterceptable;
import static org.hibernate.engine.internal.ManagedTypeHelper.processIfSelfDirtinessTracker;
import static org.hibernate.engine.internal.Versioning.isVersionIncrementRequired;
import static org.hibernate.generator.EventType.INSERT;
import static org.hibernate.generator.EventType.UPDATE;
import static org.hibernate.internal.util.ReflectHelper.isAbstractClass;
@ -324,7 +321,6 @@ import static org.hibernate.internal.util.collections.ArrayHelper.toTypeArray;
import static org.hibernate.internal.util.collections.CollectionHelper.combine;
import static org.hibernate.internal.util.collections.CollectionHelper.isNotEmpty;
import static org.hibernate.internal.util.collections.CollectionHelper.setOfSize;
import static org.hibernate.internal.util.collections.CollectionHelper.toSmallList;
import static org.hibernate.loader.ast.internal.MultiKeyLoadHelper.supportsSqlArrayType;
import static org.hibernate.metamodel.RepresentationMode.POJO;
import static org.hibernate.persister.entity.DiscriminatorHelper.NOT_NULL_DISCRIMINATOR;
@ -386,8 +382,6 @@ public abstract class AbstractEntityPersister
private final boolean[][] propertyColumnInsertable;
private final Set<String> sharedColumnNames;
private final List<Integer> lobProperties;
//information about lazy properties of this class
private final String[] lazyPropertyNames;
private final int[] lazyPropertyNumbers;
@ -443,10 +437,6 @@ public abstract class AbstractEntityPersister
private GeneratedValuesMutationDelegate updateDelegate;
private String identitySelectString;
private boolean[] tableHasColumns;
private final Map<String,String[]> subclassPropertyColumnNames = new HashMap<>();
private final JavaType<?> javaType;
private final EntityRepresentationStrategy representationStrategy;
@ -648,7 +638,6 @@ public abstract class AbstractEntityPersister
final ArrayList<Type> lazyTypes = new ArrayList<>();
final ArrayList<String[]> lazyColAliases = new ArrayList<>();
final ArrayList<Integer> lobPropertiesLocalCollector = new ArrayList<>();
final List<Property> propertyClosure = persistentClass.getPropertyClosure();
boolean foundFormula = false;
for ( int i = 0; i < propertyClosure.size(); i++ ) {
@ -709,12 +698,7 @@ public abstract class AbstractEntityPersister
propertyColumnUpdateable[i] = prop.getValue().getColumnUpdateability();
propertyColumnInsertable[i] = prop.getValue().getColumnInsertability();
if ( prop.isLob() && dialect.forceLobAsLastValue() ) {
lobPropertiesLocalCollector.add( i );
}
}
lobProperties = toSmallList( lobPropertiesLocalCollector );
hasFormulaProperties = foundFormula;
lazyPropertyColumnAliases = to2DStringArray( lazyColAliases );
lazyPropertyNames = toStringArray( lazyNames );
@ -1083,10 +1067,6 @@ public abstract class AbstractEntityPersister
return sharedColumnNames.contains( columnExpression );
}
protected boolean[] getTableHasColumns() {
return tableHasColumns;
}
@Override
public String[] getRootTableKeyColumnNames() {
return rootTableKeyColumnNames;
@ -2648,12 +2628,6 @@ public abstract class AbstractEntityPersister
);
}
@Override
public String[] getSubclassPropertyColumnNames(String propertyName) {
//TODO: should we allow suffixes on these ?
return subclassPropertyColumnNames.get( propertyName );
}
@Override
public Object loadByUniqueKey(
String propertyName,
@ -3439,13 +3413,6 @@ public abstract class AbstractEntityPersister
final int joinSpan = getTableSpan();
tableHasColumns = new boolean[joinSpan];
for ( int j = 0; j < joinSpan; j++ ) {
final String tableName = getTableName( j );
final EntityTableMapping tableMapping = findTableMapping( tableName );
tableHasColumns[j] = tableMapping.hasColumns();
}
//select SQL
sqlVersionSelectString = generateSelectVersionString();
}
@ -4313,11 +4280,6 @@ public abstract class AbstractEntityPersister
return propertyMapping.toType( propertyName );
}
@Override
public Type getType() {
return entityMetamodel.getEntityType();
}
@Override
public boolean isSelectBeforeUpdateRequired() {
return entityMetamodel.isSelectBeforeUpdate();
@ -6423,13 +6385,11 @@ public abstract class AbstractEntityPersister
// aliases for identifier ( alias.id ); skip if the entity defines a non-id property named 'id'
if ( !entityMetamodel.hasNonIdentifierPropertyNamedId() ) {
subclassPropertyAliases.put( ENTITY_ID, getIdentifierAliases() );
subclassPropertyColumnNames.put( ENTITY_ID, getIdentifierColumnNames() );
}
// aliases named identifier ( alias.idname )
if ( hasIdentifierProperty() ) {
subclassPropertyAliases.put( getIdentifierPropertyName(), getIdentifierAliases() );
subclassPropertyColumnNames.put( getIdentifierPropertyName(), getIdentifierColumnNames() );
}
// aliases for composite-id's
@ -6446,10 +6406,6 @@ public abstract class AbstractEntityPersister
ENTITY_ID + "." + idPropertyNames[i],
new String[] {idAliases[i]}
);
subclassPropertyColumnNames.put(
ENTITY_ID + "." + getIdentifierPropertyName() + "." + idPropertyNames[i],
new String[] {idColumnNames[i]}
);
}
// if (hasIdentifierProperty() && !ENTITY_ID.equals( getIdentifierPropertyNames() ) ) {
if ( hasIdentifierProperty() ) {
@ -6457,22 +6413,16 @@ public abstract class AbstractEntityPersister
getIdentifierPropertyName() + "." + idPropertyNames[i],
new String[] {idAliases[i]}
);
subclassPropertyColumnNames.put(
getIdentifierPropertyName() + "." + idPropertyNames[i],
new String[] {idColumnNames[i]}
);
}
else {
// embedded composite ids ( alias.idName1, alias.idName2 )
subclassPropertyAliases.put( idPropertyNames[i], new String[] {idAliases[i]} );
subclassPropertyColumnNames.put( idPropertyNames[i], new String[] {idColumnNames[i]} );
}
}
}
if ( entityMetamodel.isPolymorphic() ) {
subclassPropertyAliases.put( ENTITY_CLASS, new String[] {getDiscriminatorAlias()} );
subclassPropertyColumnNames.put( ENTITY_CLASS, new String[] {getDiscriminatorColumnName()} );
}
}
@ -6496,7 +6446,6 @@ public abstract class AbstractEntityPersister
}
subclassPropertyAliases.put( name, aliases );
subclassPropertyColumnNames.put( name, cols );
}
}

View File

@ -12,5 +12,5 @@ package org.hibernate.persister.entity;
*/
@Deprecated
public interface DeprecatedEntityStuff
extends OuterJoinLoadable, UniqueKeyLoadable, SQLLoadable, Lockable, Queryable {
extends OuterJoinLoadable, UniqueKeyLoadable, Loadable, Lockable, Queryable {
}

View File

@ -92,15 +92,6 @@ public interface Loadable extends EntityPersister {
boolean isAbstract();
/**
* Register the name of a fetch profile determined to have an affect on the
* underlying loadable in regards to the fact that the underlying load SQL
* needs to be adjust when the given fetch profile is enabled.
*
* @param fetchProfileName The name of the profile affecting this.
*/
void registerAffectingFetchProfile(String fetchProfileName);
/**
* Given a column name and the root table alias in use for the entity hierarchy, determine the proper table alias
* for the table in that hierarchy that contains said column.
@ -114,4 +105,14 @@ public interface Loadable extends EntityPersister {
* @return The proper table alias for qualifying the given column.
*/
String getTableAliasForColumn(String columnName, String rootAlias);
/**
* All columns to select, when loading.
*/
String selectFragment(String alias, String suffix);
/**
* Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
*/
String[] getSubclassPropertyColumnAliases(String propertyName, String suffix);
}

View File

@ -1,43 +0,0 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
package org.hibernate.persister.entity;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.type.Type;
/**
* An {@link EntityPersister} that supports queries expressed
* in the platform native SQL dialect.
*
* @author Gavin King, Max Andersen
*
* @deprecated Use {@link EntityMappingType}
*/
@Deprecated(since = "6", forRemoval = true)
public interface SQLLoadable extends Loadable {
/**
* Return the column alias names used to persist/query the named property of the class or a subclass (optional operation).
*/
String[] getSubclassPropertyColumnAliases(String propertyName, String suffix);
/**
* Return the column names used to persist/query the named property of the class or a subclass (optional operation).
*/
String[] getSubclassPropertyColumnNames(String propertyName);
/**
* All columns to select, when loading.
*/
String selectFragment(String alias, String suffix);
/**
* Get the type
*/
Type getType();
}

View File

@ -33,7 +33,6 @@ import org.hibernate.dialect.Dialect;
import org.hibernate.id.IdentityGenerator;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.internal.StaticFilterAliasGenerator;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.JoinedList;
import org.hibernate.jdbc.Expectation;
import org.hibernate.mapping.Column;
@ -446,10 +445,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
return 1;
}
protected boolean[] getTableHasColumns() {
return ArrayHelper.TRUE;
}
@Override
protected int[] getPropertyTableNumbers() {
return new int[getPropertySpan()];

View File

@ -27,10 +27,8 @@ import org.hibernate.metamodel.mapping.CollectionPart;
import org.hibernate.metamodel.mapping.EntityMappingType;
import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.persister.entity.SQLLoadable;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.results.FetchBuilder;
import org.hibernate.query.results.ResultSetMapping;
@ -236,7 +234,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
null,
determineNavigablePath( fetchBuilder )
);
final SQLLoadable loadable = (SQLLoadable) alias2Persister.get( fetchBuilder.getOwnerAlias() );
final Loadable loadable = (Loadable) alias2Persister.get( fetchBuilder.getOwnerAlias() );
final List<String> columnNames;
final String[] columnAliases = loadable.getSubclassPropertyColumnAliases(
fetchBuilder.getFetchableName(),
@ -308,7 +306,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
String suffix,
LockMode lockMode,
NavigablePath navigablePath) {
final SQLLoadable loadable = (SQLLoadable) entityMapping.getEntityPersister();
final Loadable loadable = (Loadable) entityMapping.getEntityPersister();
final DynamicResultBuilderEntityStandard resultBuilderEntity = new DynamicResultBuilderEntityStandard(
entityMapping,
tableAlias,
@ -347,7 +345,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
private void addFetchBuilder(
String suffix,
SQLLoadable loadable,
Loadable loadable,
DynamicFetchBuilderContainer resultBuilderEntity,
String tableAlias,
String[] identifierAliases,
@ -441,14 +439,14 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
);
}
private SQLLoadable getSQLLoadable(String entityName) throws MappingException {
private Loadable getSQLLoadable(String entityName) throws MappingException {
final EntityPersister entityDescriptor = factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getEntityDescriptor( entityName );
if ( !(entityDescriptor instanceof SQLLoadable) ) {
throw new MappingException( "class persister is not SQLLoadable: " + entityName );
if ( !(entityDescriptor instanceof Loadable) ) {
throw new MappingException( "class persister is not Loadable: " + entityName );
}
return (SQLLoadable) entityDescriptor;
return (Loadable) entityDescriptor;
}
private String generateEntitySuffix() {
@ -501,12 +499,12 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
return;
}
SQLLoadable persister = (SQLLoadable) rootReturn.getEntityMapping().getEntityPersister();
Loadable persister = (Loadable) rootReturn.getEntityMapping().getEntityPersister();
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//rootReturn.getPropertyResultsMap()
addPersister( rootReturn.getTableAlias(), propertyResultsMap, persister );
}
private void addPersister(String alias, Map<String, String[]> propertyResult, SQLLoadable persister) {
private void addPersister(String alias, Map<String, String[]> propertyResult, Loadable persister) {
alias2Persister.put( alias, persister );
String suffix = generateEntitySuffix();
LOG.tracev( "Mapping alias [{0}] to entity-suffix [{1}]", alias, suffix );
@ -516,9 +514,9 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
private void addCollection(String role, String alias, Map<String, String[]> propertyResults) {
final SQLLoadableCollection collectionDescriptor = (SQLLoadableCollection) factory.getRuntimeMetamodels()
.getMappingMetamodel()
.getCollectionDescriptor( role );
final QueryableCollection collectionDescriptor = (QueryableCollection)
factory.getRuntimeMetamodels().getMappingMetamodel()
.getCollectionDescriptor( role );
alias2CollectionPersister.put( alias, collectionDescriptor );
String suffix = generateCollectionSuffix();
@ -527,7 +525,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
collectionPropertyResultMaps.put( alias, propertyResults );
if ( collectionDescriptor.isOneToMany() || collectionDescriptor.isManyToMany() ) {
SQLLoadable persister = ( SQLLoadable ) collectionDescriptor.getElementPersister();
Loadable persister = (Loadable) collectionDescriptor.getElementPersister();
addPersister( alias, filter( propertyResults ), persister );
}
}
@ -565,7 +563,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
processReturn( alias2Return.get( ownerAlias ) );
}
SQLLoadable ownerPersister = ( SQLLoadable ) alias2Persister.get( ownerAlias );
Loadable ownerPersister = (Loadable) alias2Persister.get( ownerAlias );
Type returnType = ownerPersister.getPropertyType( fetchReturn.getFetchableName() );
if ( returnType.isCollectionType() ) {
@ -577,7 +575,7 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
else if ( returnType.isEntityType() ) {
EntityType eType = ( EntityType ) returnType;
String returnEntityName = eType.getAssociatedEntityName();
SQLLoadable persister = getSQLLoadable( returnEntityName );
Loadable persister = getSQLLoadable( returnEntityName );
Map<String, String[]> propertyResultsMap = Collections.emptyMap();//fetchReturn.getPropertyResultsMap()
addPersister( alias, propertyResultsMap, persister );
}
@ -594,13 +592,13 @@ public class ResultSetMappingProcessor implements SQLQueryParser.ParserContext {
}
@Override
public SQLLoadable getEntityPersister(String alias) {
return (SQLLoadable) alias2Persister.get( alias );
public Loadable getEntityPersister(String alias) {
return (Loadable) alias2Persister.get( alias );
}
@Override
public SQLLoadableCollection getCollectionPersister(String alias) {
return (SQLLoadableCollection) alias2CollectionPersister.get( alias );
public QueryableCollection getCollectionPersister(String alias) {
return (QueryableCollection) alias2CollectionPersister.get( alias );
}
@Override

View File

@ -13,8 +13,8 @@ import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.persister.collection.SQLLoadableCollection;
import org.hibernate.persister.entity.SQLLoadable;
import org.hibernate.persister.collection.QueryableCollection;
import org.hibernate.persister.entity.Loadable;
/**
* Substitutes escape sequences of form {@code {alias}},
@ -36,10 +36,10 @@ public class SQLQueryParser {
public interface ParserContext {
boolean isEntityAlias(String aliasName);
SQLLoadable getEntityPersister(String alias);
Loadable getEntityPersister(String alias);
String getEntitySuffix(String alias);
boolean isCollectionAlias(String aliasName);
SQLLoadableCollection getCollectionPersister(String alias);
QueryableCollection getCollectionPersister(String alias);
String getCollectionSuffix(String alias);
Map<String, String[]> getPropertyResultsMap(String alias);
}
@ -207,7 +207,7 @@ public class SQLQueryParser {
String aliasName,
String propertyName) {
final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName );
final SQLLoadableCollection collectionPersister = context.getCollectionPersister( aliasName );
final QueryableCollection collectionPersister = context.getCollectionPersister( aliasName );
final String collectionSuffix = context.getCollectionSuffix( aliasName );
switch ( propertyName ) {
case "*":
@ -234,7 +234,7 @@ public class SQLQueryParser {
private String resolveProperties(String aliasName, String propertyName) {
final Map<String, String[]> fieldResults = context.getPropertyResultsMap( aliasName );
final SQLLoadable persister = context.getEntityPersister( aliasName );
final Loadable persister = context.getEntityPersister( aliasName );
final String suffix = context.getEntitySuffix( aliasName );
if ( "*".equals( propertyName ) ) {
if ( !fieldResults.isEmpty() ) {