remove OuterJoinLoadable, UniqueKeyLoadable, PersisterCreationContext
Signed-off-by: Gavin King <gavin@hibernate.org>
This commit is contained in:
parent
4013246d75
commit
38d1a8bb83
|
@ -14,7 +14,6 @@ import org.hibernate.cache.spi.CacheImplementor;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
|
@ -25,7 +24,7 @@ import java.util.Map;
|
|||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface RuntimeModelCreationContext extends PersisterCreationContext {
|
||||
public interface RuntimeModelCreationContext {
|
||||
SessionFactoryImplementor getSessionFactory();
|
||||
|
||||
BootstrapContext getBootstrapContext();
|
||||
|
@ -42,7 +41,6 @@ public interface RuntimeModelCreationContext extends PersisterCreationContext {
|
|||
return getTypeConfiguration().getJavaTypeRegistry();
|
||||
}
|
||||
|
||||
@Override
|
||||
default MetadataImplementor getMetadata() {
|
||||
return getBootModel();
|
||||
}
|
||||
|
|
|
@ -98,7 +98,6 @@ import org.hibernate.persister.entity.EntityPersister;
|
|||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.entity.PropertyMapping;
|
||||
import org.hibernate.persister.internal.SqlFragmentPredicate;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.pretty.MessageHelper;
|
||||
import org.hibernate.query.named.NamedQueryMemento;
|
||||
import org.hibernate.query.spi.QueryOptions;
|
||||
|
@ -253,15 +252,6 @@ public abstract class AbstractCollectionPersister
|
|||
private PluralAttributeMapping attributeMapping;
|
||||
private volatile Set<String> affectingFetchProfiles;
|
||||
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public AbstractCollectionPersister(
|
||||
Collection collectionBootDescriptor,
|
||||
@Nullable CollectionDataAccess cacheAccessStrategy,
|
||||
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||
this( collectionBootDescriptor, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public AbstractCollectionPersister(
|
||||
Collection collectionBootDescriptor,
|
||||
@Nullable CollectionDataAccess cacheAccessStrategy,
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.hibernate.persister.collection.mutation.RowMutationOperations;
|
|||
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinator;
|
||||
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorNoOp;
|
||||
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorStandard;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
@ -81,14 +80,6 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
|
|||
private final DeleteRowsCoordinator deleteRowsCoordinator;
|
||||
private final RemoveCoordinator removeCoordinator;
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public BasicCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||
this( collectionBinding, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public BasicCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
|
|
|
@ -57,7 +57,6 @@ import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorOneToMan
|
|||
import org.hibernate.persister.collection.mutation.UpdateRowsCoordinatorTablePerSubclass;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.entity.UnionSubclassEntityPersister;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.sql.ast.SqlAstTranslator;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
import org.hibernate.sql.ast.tree.expression.ColumnReference;
|
||||
|
@ -103,14 +102,6 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
|||
private final boolean keyIsNullable;
|
||||
private final MutationExecutorService mutationExecutorService;
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public OneToManyPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||
this( collectionBinding, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public OneToManyPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
|
|
|
@ -42,7 +42,6 @@ import org.hibernate.LockOptions;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.PropertyValueException;
|
||||
import org.hibernate.QueryException;
|
||||
import org.hibernate.Remove;
|
||||
import org.hibernate.StaleObjectStateException;
|
||||
import org.hibernate.StaleStateException;
|
||||
import org.hibernate.annotations.CacheLayout;
|
||||
|
@ -111,7 +110,6 @@ import org.hibernate.graph.spi.RootGraphImplementor;
|
|||
import org.hibernate.id.BulkInsertionCapableIdentifierGenerator;
|
||||
import org.hibernate.id.IdentifierGenerator;
|
||||
import org.hibernate.id.OptimizableGenerator;
|
||||
import org.hibernate.id.PostInsertIdentityPersister;
|
||||
import org.hibernate.id.enhanced.Optimizer;
|
||||
import org.hibernate.internal.CoreLogging;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
|
@ -161,7 +159,6 @@ import org.hibernate.metamodel.mapping.AttributeMapping;
|
|||
import org.hibernate.metamodel.mapping.AttributeMappingsList;
|
||||
import org.hibernate.metamodel.mapping.AttributeMappingsMap;
|
||||
import org.hibernate.metamodel.mapping.AttributeMetadata;
|
||||
import org.hibernate.metamodel.mapping.DiscriminatedAssociationModelPart;
|
||||
import org.hibernate.metamodel.mapping.DiscriminatorConverter;
|
||||
import org.hibernate.metamodel.mapping.DiscriminatorType;
|
||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||
|
@ -183,7 +180,6 @@ import org.hibernate.metamodel.mapping.SelectableConsumer;
|
|||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||
import org.hibernate.metamodel.mapping.SingularAttributeMapping;
|
||||
import org.hibernate.metamodel.mapping.SoftDeleteMapping;
|
||||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.mapping.VirtualModelPart;
|
||||
import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl;
|
||||
import org.hibernate.metamodel.mapping.internal.CompoundNaturalIdMapping;
|
||||
|
@ -201,7 +197,6 @@ import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper;
|
|||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
||||
import org.hibernate.metamodel.mapping.internal.SimpleAttributeMetadata;
|
||||
import org.hibernate.metamodel.mapping.internal.SimpleNaturalIdMapping;
|
||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.EntityInstantiator;
|
||||
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
|
||||
|
@ -313,7 +308,6 @@ import static org.hibernate.internal.util.StringHelper.isEmpty;
|
|||
import static org.hibernate.internal.util.StringHelper.qualifyConditionally;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.contains;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.to2DStringArray;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toBooleanArray;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toIntArray;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toObjectArray;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toStringArray;
|
||||
|
@ -334,8 +328,9 @@ import static org.hibernate.sql.ast.spi.SqlExpressionResolver.createColumnRefere
|
|||
* @author Gavin King
|
||||
*/
|
||||
@Internal
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractEntityPersister
|
||||
implements InFlightEntityMappingType, EntityMutationTarget, LazyPropertyInitializer, PostInsertIdentityPersister, FetchProfileAffectee, DeprecatedEntityStuff {
|
||||
implements InFlightEntityMappingType, EntityMutationTarget, LazyPropertyInitializer, FetchProfileAffectee, DeprecatedEntityStuff {
|
||||
|
||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
|
||||
|
||||
|
@ -373,11 +368,9 @@ public abstract class AbstractEntityPersister
|
|||
//information about properties of this class,
|
||||
//including inherited properties
|
||||
//(only really needed for updatable/insertable properties)
|
||||
private final int[] propertyColumnSpans;
|
||||
private final String[][] propertyColumnAliases;
|
||||
private final String[][] propertyColumnNames;
|
||||
private final String[][] propertyColumnFormulaTemplates;
|
||||
private final String[][] propertyColumnWriters;
|
||||
private final boolean[][] propertyColumnUpdateable;
|
||||
private final boolean[][] propertyColumnInsertable;
|
||||
private final Set<String> sharedColumnNames;
|
||||
|
@ -396,9 +389,6 @@ public abstract class AbstractEntityPersister
|
|||
private final String[][] subclassPropertyColumnReaderClosure;
|
||||
private final String[][] subclassPropertyColumnReaderTemplateClosure;
|
||||
private final FetchMode[] subclassPropertyFetchModeClosure;
|
||||
private final boolean[] subclassPropertyNullabilityClosure;
|
||||
private final boolean[] propertyDefinedOnSubclass;
|
||||
private final CascadeStyle[] subclassPropertyCascadeStyleClosure;
|
||||
|
||||
private Map<String, SingleIdArrayLoadPlan> lazyLoadPlanByFetchGroup;
|
||||
private final LockModeEnumMap<LockingStrategy> lockers = new LockModeEnumMap<>();
|
||||
|
@ -482,16 +472,6 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
private List<UniqueKeyEntry> uniqueKeyEntries = null; //lazily initialized
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public AbstractEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
final PersisterCreationContext creationContext) throws HibernateException {
|
||||
this( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy,
|
||||
(RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public AbstractEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
|
@ -623,11 +603,9 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
// PROPERTIES
|
||||
final int hydrateSpan = entityMetamodel.getPropertySpan();
|
||||
propertyColumnSpans = new int[hydrateSpan];
|
||||
propertyColumnAliases = new String[hydrateSpan][];
|
||||
propertyColumnNames = new String[hydrateSpan][];
|
||||
propertyColumnFormulaTemplates = new String[hydrateSpan][];
|
||||
propertyColumnWriters = new String[hydrateSpan][];
|
||||
propertyColumnUpdateable = new boolean[hydrateSpan][];
|
||||
propertyColumnInsertable = new boolean[hydrateSpan][];
|
||||
sharedColumnNames = new HashSet<>();
|
||||
|
@ -645,11 +623,8 @@ public abstract class AbstractEntityPersister
|
|||
thisClassProperties.add( prop );
|
||||
|
||||
final int span = prop.getColumnSpan();
|
||||
propertyColumnSpans[i] = span;
|
||||
|
||||
final String[] colNames = new String[span];
|
||||
final String[] colAliases = new String[span];
|
||||
final String[] colWriters = new String[span];
|
||||
final String[] formulaTemplates = new String[span];
|
||||
final List<Selectable> selectables = prop.getSelectables();
|
||||
for ( int k = 0; k < selectables.size(); k++ ) {
|
||||
|
@ -668,12 +643,10 @@ public abstract class AbstractEntityPersister
|
|||
else {
|
||||
final Column column = (Column) selectable;
|
||||
colNames[k] = column.getQuotedName( dialect );
|
||||
colWriters[k] = column.getWriteExpr( prop.getValue().getSelectableType( creationContext.getMetadata(), k ), dialect );
|
||||
}
|
||||
}
|
||||
propertyColumnNames[i] = colNames;
|
||||
propertyColumnFormulaTemplates[i] = formulaTemplates;
|
||||
propertyColumnWriters[i] = colWriters;
|
||||
propertyColumnAliases[i] = colAliases;
|
||||
|
||||
final boolean lazy = !EnhancementHelper.includeInBaseFetchGroup(
|
||||
|
@ -715,18 +688,11 @@ public abstract class AbstractEntityPersister
|
|||
final ArrayList<String[]> propColumnReaders = new ArrayList<>();
|
||||
final ArrayList<String[]> propColumnReaderTemplates = new ArrayList<>();
|
||||
final ArrayList<FetchMode> joinedFetchesList = new ArrayList<>();
|
||||
final ArrayList<CascadeStyle> cascades = new ArrayList<>();
|
||||
final ArrayList<Boolean> definedBySubclass = new ArrayList<>();
|
||||
final ArrayList<Boolean> propNullables = new ArrayList<>();
|
||||
|
||||
for ( Property prop : persistentClass.getSubclassPropertyClosure() ) {
|
||||
names.add( prop.getName() );
|
||||
types.add( prop.getType() );
|
||||
|
||||
final boolean isDefinedBySubclass = !thisClassProperties.contains( prop );
|
||||
definedBySubclass.add( isDefinedBySubclass );
|
||||
propNullables.add( prop.isOptional() || isDefinedBySubclass ); //TODO: is this completely correct?
|
||||
|
||||
final String[] cols = new String[ prop.getColumnSpan() ];
|
||||
final String[] readers = new String[ prop.getColumnSpan() ];
|
||||
final String[] readerTemplates = new String[ prop.getColumnSpan() ];
|
||||
|
@ -762,8 +728,9 @@ public abstract class AbstractEntityPersister
|
|||
typeConfiguration,
|
||||
functionRegistry
|
||||
);
|
||||
if ( isDefinedBySubclass && persistentClass.isDefinedOnMultipleSubclasses( column )
|
||||
|| !isDefinedBySubclass && persistentClass.hasSubclasses() ) {
|
||||
if ( thisClassProperties.contains( prop )
|
||||
? persistentClass.hasSubclasses()
|
||||
: persistentClass.isDefinedOnMultipleSubclasses( column ) ) {
|
||||
sharedColumnNames.add( colName );
|
||||
}
|
||||
}
|
||||
|
@ -774,32 +741,35 @@ public abstract class AbstractEntityPersister
|
|||
templates.add( forms );
|
||||
|
||||
joinedFetchesList.add( prop.getValue().getFetchMode() );
|
||||
cascades.add( prop.getCascadeStyle() );
|
||||
}
|
||||
subclassColumnAliasClosure = toStringArray( aliases );
|
||||
subclassFormulaAliasClosure = toStringArray( formulaAliases );
|
||||
|
||||
subclassPropertyNameClosure = toStringArray( names );
|
||||
subclassPropertyTypeClosure = toTypeArray( types );
|
||||
subclassPropertyNullabilityClosure = toBooleanArray( propNullables );
|
||||
subclassPropertyFormulaTemplateClosure = to2DStringArray( templates );
|
||||
subclassPropertyColumnNameClosure = to2DStringArray( propColumns );
|
||||
subclassPropertyColumnReaderClosure = to2DStringArray( propColumnReaders );
|
||||
subclassPropertyColumnReaderTemplateClosure = to2DStringArray( propColumnReaderTemplates );
|
||||
|
||||
subclassPropertyCascadeStyleClosure = new CascadeStyle[cascades.size()];
|
||||
int j = 0;
|
||||
for (CascadeStyle cascade: cascades) {
|
||||
subclassPropertyCascadeStyleClosure[j++] = cascade;
|
||||
}
|
||||
subclassPropertyFetchModeClosure = new FetchMode[joinedFetchesList.size()];
|
||||
j = 0;
|
||||
int j = 0;
|
||||
for (FetchMode fetchMode : joinedFetchesList) {
|
||||
subclassPropertyFetchModeClosure[j++] = fetchMode;
|
||||
}
|
||||
|
||||
propertyDefinedOnSubclass = toBooleanArray( definedBySubclass );
|
||||
|
||||
// Handle any filters applied to the class level
|
||||
filterHelper = isNotEmpty( persistentClass.getFilters() ) ? new FilterHelper(
|
||||
persistentClass.getFilters(),
|
||||
getEntityNameByTableNameMap(
|
||||
persistentClass,
|
||||
factory.getSqlStringGenerationContext()
|
||||
),
|
||||
factory
|
||||
) : null;
|
||||
|
||||
useReferenceCacheEntries = shouldUseReferenceCacheEntries( creationContext.getSessionFactoryOptions() );
|
||||
useShallowQueryCacheLayout = shouldUseShallowCacheLayout(
|
||||
persistentClass.getQueryCacheLayout(),
|
||||
|
@ -1023,10 +993,14 @@ public abstract class AbstractEntityPersister
|
|||
|
||||
protected abstract int[] getPropertyTableNumbers();
|
||||
|
||||
protected abstract int getSubclassPropertyTableNumber(int i);
|
||||
|
||||
private static final String DISCRIMINATOR_ALIAS = "clazz_";
|
||||
|
||||
/**
|
||||
* The name of the table to use when performing mutations (INSERT,UPDATE,DELETE)
|
||||
* for the given attribute
|
||||
*/
|
||||
public abstract String getAttributeMutationTableName(int i);
|
||||
|
||||
@Override
|
||||
public String getDiscriminatorColumnName() {
|
||||
return DISCRIMINATOR_ALIAS;
|
||||
|
@ -1100,12 +1074,14 @@ public abstract class AbstractEntityPersister
|
|||
return sqlVersionSelectString;
|
||||
}
|
||||
|
||||
@Internal
|
||||
@Internal // called by Hibernate Reactive
|
||||
@SuppressWarnings("unused")
|
||||
public GeneratedValuesProcessor getInsertGeneratedValuesProcessor() {
|
||||
return insertGeneratedValuesProcessor;
|
||||
}
|
||||
|
||||
@Internal
|
||||
@Internal // called by Hibernate Reactive
|
||||
@SuppressWarnings("unused")
|
||||
public GeneratedValuesProcessor getUpdateGeneratedValuesProcessor() {
|
||||
return updateGeneratedValuesProcessor;
|
||||
}
|
||||
|
@ -1115,22 +1091,6 @@ public abstract class AbstractEntityPersister
|
|||
return rowIdName != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate Reactive
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public boolean[][] getPropertyColumnUpdateable() {
|
||||
return propertyColumnUpdateable;
|
||||
}
|
||||
|
||||
/**
|
||||
* For Hibernate Reactive
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public boolean[][] getPropertyColumnInsertable() {
|
||||
return propertyColumnInsertable;
|
||||
}
|
||||
|
||||
public String[] getTableNames() {
|
||||
final String[] tableNames = new String[getTableSpan()];
|
||||
for ( int i = 0; i < tableNames.length; i++ ) {
|
||||
|
@ -1542,10 +1502,6 @@ public abstract class AbstractEntityPersister
|
|||
persistenceContext.addUninitializedCollection( persister, collection, key );
|
||||
}
|
||||
|
||||
// // HHH-11161 Initialize, if the collection is not extra lazy
|
||||
// if ( !persister.isExtraLazy() ) {
|
||||
// session.initializeCollection( collection, false );
|
||||
// }
|
||||
interceptor.attributeInitialized( fieldName );
|
||||
|
||||
if ( collectionType.isArrayType() ) {
|
||||
|
@ -1987,19 +1943,11 @@ public abstract class AbstractEntityPersister
|
|||
return fetches.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Fetchable#isSelectable()} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isSelectable(FetchParent fetchParent, Fetchable fetchable) {
|
||||
return fetchable.isSelectable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getIdentifierAliases(String suffix) {
|
||||
// NOTE: this assumes something about how propertySelectFragment is implemented by the subclass!
|
||||
// was toUnquotedAliasStrings( getIdentifierColumnNames() ) before - now tried
|
||||
// to remove that unquoting and missing aliases..
|
||||
// to remove that unquoting and missing aliases
|
||||
return new Alias( suffix ).toAliasStrings( getIdentifierAliases() );
|
||||
}
|
||||
|
||||
|
@ -2013,7 +1961,7 @@ public abstract class AbstractEntityPersister
|
|||
public String getDiscriminatorAlias(String suffix) {
|
||||
// NOTE: this assumes something about how propertySelectFragment is implemented by the subclass!
|
||||
// toUnquotedAliasStrings( getDiscriminatorColumnName() ) before - now tried
|
||||
// to remove that unquoting and missing aliases..
|
||||
// to remove that unquoting and missing aliases
|
||||
return entityMetamodel.hasSubclasses()
|
||||
? new Alias( suffix ).toAliasString( getDiscriminatorAlias() )
|
||||
: null;
|
||||
|
@ -2254,7 +2202,7 @@ public abstract class AbstractEntityPersister
|
|||
* Warning:
|
||||
* When there are duplicated property names in the subclasses
|
||||
* of the class, this method may return the wrong table
|
||||
* number for the duplicated subclass property (note that
|
||||
* number for the duplicated subclass property. Note that
|
||||
* SingleTableEntityPersister defines an overloaded form
|
||||
* which takes the entity name.
|
||||
*/
|
||||
|
@ -2300,32 +2248,6 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPropertyTableName(String propertyName) {
|
||||
final AttributeMapping attributeMapping = findAttributeMapping( propertyName );
|
||||
if ( attributeMapping instanceof SelectableMapping ) {
|
||||
return ( (SelectableMapping) attributeMapping ).getContainingTableExpression();
|
||||
}
|
||||
else if ( attributeMapping instanceof EmbeddableValuedModelPart ) {
|
||||
return attributeMapping.getContainingTableExpression();
|
||||
}
|
||||
else if ( attributeMapping instanceof DiscriminatedAssociationModelPart ) {
|
||||
return ( (DiscriminatedAssociationModelPart) attributeMapping ).getDiscriminatorPart()
|
||||
.getContainingTableExpression();
|
||||
}
|
||||
else if ( attributeMapping instanceof ToOneAttributeMapping ) {
|
||||
final ToOneAttributeMapping toOneAttributeMapping = (ToOneAttributeMapping) attributeMapping;
|
||||
if ( toOneAttributeMapping.getSideNature() == ForeignKeyDescriptor.Nature.KEY ) {
|
||||
return toOneAttributeMapping.getForeignKeyDescriptor().getKeyTable();
|
||||
}
|
||||
else {
|
||||
return toOneAttributeMapping.getForeignKeyDescriptor().getTargetTable();
|
||||
}
|
||||
}
|
||||
assert attributeMapping instanceof PluralAttributeMapping;
|
||||
return ( (PluralAttributeMapping) attributeMapping ).getKeyDescriptor().getKeyTable();
|
||||
}
|
||||
|
||||
private DiscriminatorType discriminatorType;
|
||||
|
||||
|
||||
|
@ -2382,20 +2304,6 @@ public abstract class AbstractEntityPersister
|
|||
return alias.append( tableNumber ).append( '_' ).toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] toColumns(String name, final int i) {
|
||||
final String alias = generateTableAlias( name, getSubclassPropertyTableNumber( i ) );
|
||||
final String[] cols = getSubclassPropertyColumnNames( i );
|
||||
final String[] templates = getSubclassPropertyFormulaTemplateClosure()[i];
|
||||
final String[] result = new String[cols.length];
|
||||
for ( int j = 0; j < cols.length; j++ ) {
|
||||
result[j] = cols[j] == null
|
||||
? StringHelper.replace( templates[j], Template.TEMPLATE, alias )
|
||||
: StringHelper.qualify( alias, cols[j] );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getSubclassPropertyIndex(String propertyName) {
|
||||
return ArrayHelper.indexOf( subclassPropertyNameClosure, propertyName );
|
||||
}
|
||||
|
@ -2405,14 +2313,6 @@ public abstract class AbstractEntityPersister
|
|||
return propertyColumnNames[i];
|
||||
}
|
||||
|
||||
public String[] getPropertyColumnWriters(int i) {
|
||||
return propertyColumnWriters[i];
|
||||
}
|
||||
|
||||
public int getPropertyColumnSpan(int i) {
|
||||
return propertyColumnSpans[i];
|
||||
}
|
||||
|
||||
public boolean hasFormulaProperties() {
|
||||
return hasFormulaProperties;
|
||||
}
|
||||
|
@ -2422,36 +2322,19 @@ public abstract class AbstractEntityPersister
|
|||
return subclassPropertyFetchModeClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public CascadeStyle getCascadeStyle(int i) {
|
||||
return subclassPropertyCascadeStyleClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type getSubclassPropertyType(int i) {
|
||||
return subclassPropertyTypeClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubclassPropertyName(int i) {
|
||||
return subclassPropertyNameClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countSubclassProperties() {
|
||||
return subclassPropertyTypeClosure.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getSubclassPropertyColumnNames(int i) {
|
||||
return subclassPropertyColumnNameClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDefinedOnSubclass(int i) {
|
||||
return propertyDefinedOnSubclass[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[][] getSubclassPropertyFormulaTemplateClosure() {
|
||||
return subclassPropertyFormulaTemplateClosure;
|
||||
|
@ -3411,8 +3294,6 @@ public abstract class AbstractEntityPersister
|
|||
deleteCoordinator = buildDeleteCoordinator();
|
||||
mergeCoordinator = buildMergeCoordinator();
|
||||
|
||||
final int joinSpan = getTableSpan();
|
||||
|
||||
//select SQL
|
||||
sqlVersionSelectString = generateSelectVersionString();
|
||||
}
|
||||
|
@ -3429,15 +3310,6 @@ public abstract class AbstractEntityPersister
|
|||
return GeneratedValuesHelper.getGeneratedValuesDelegate( this, UPDATE );
|
||||
}
|
||||
|
||||
private EntityTableMapping findTableMapping(String tableName) {
|
||||
for ( int i = 0; i < tableMappings.length; i++ ) {
|
||||
if ( tableMappings[i].getTableName().equals( tableName ) ) {
|
||||
return tableMappings[i];
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException( "Unknown table : " + tableName );
|
||||
}
|
||||
|
||||
private static class TableMappingBuilder {
|
||||
private final String tableName;
|
||||
private final int relativePosition;
|
||||
|
@ -3848,11 +3720,6 @@ public abstract class AbstractEntityPersister
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSubclassPropertyNullable(int i) {
|
||||
return subclassPropertyNullabilityClosure[i];
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the property-indices of all properties considered to be dirty.
|
||||
*
|
||||
|
@ -3990,11 +3857,6 @@ public abstract class AbstractEntityPersister
|
|||
return entityMetamodel.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntityType() {
|
||||
return entityMetamodel.getEntityType();
|
||||
}
|
||||
|
||||
public boolean isPolymorphic() {
|
||||
return entityMetamodel.isPolymorphic();
|
||||
}
|
||||
|
@ -4051,16 +3913,6 @@ public abstract class AbstractEntityPersister
|
|||
return entityMetamodel.hasLazyProperties();
|
||||
}
|
||||
|
||||
// public boolean hasUninitializedLazyProperties(Object entity) {
|
||||
// if ( hasLazyProperties() ) {
|
||||
// InterceptFieldCallback callback = ( ( InterceptFieldEnabled ) entity ).getInterceptFieldCallback();
|
||||
// return callback != null && !( ( FieldInterceptor ) callback ).isInitialized();
|
||||
// }
|
||||
// else {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void afterReassociate(Object entity, SharedSessionContractImplementor session) {
|
||||
final BytecodeEnhancementMetadata metadata = getEntityMetamodel().getBytecodeEnhancementMetadata();
|
||||
|
@ -5936,11 +5788,6 @@ public abstract class AbstractEntityPersister
|
|||
return softDeleteMapping;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDetails getSoftDeleteTableDetails() {
|
||||
return getIdentifierTableDetails();
|
||||
}
|
||||
|
||||
@Override
|
||||
public AttributeMappingsList getAttributeMappings() {
|
||||
if ( attributeMappings == null ) {
|
||||
|
@ -6152,11 +5999,6 @@ public abstract class AbstractEntityPersister
|
|||
return superMappingType == null ? getNumberOfFetchables() : getRootEntityDescriptor().getNumberOfFetchables();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNumberOfKeyFetchables() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fetchable getKeyFetchable(int position) {
|
||||
throw new IndexOutOfBoundsException( position );
|
||||
|
@ -6398,7 +6240,6 @@ public abstract class AbstractEntityPersister
|
|||
final CompositeType componentId = (CompositeType) getIdentifierType();
|
||||
final String[] idPropertyNames = componentId.getPropertyNames();
|
||||
final String[] idAliases = getIdentifierAliases();
|
||||
final String[] idColumnNames = getIdentifierColumnNames();
|
||||
|
||||
for ( int i = 0; i < idPropertyNames.length; i++ ) {
|
||||
if ( entityMetamodel.hasNonIdentifierPropertyNamedId() ) {
|
||||
|
@ -6436,12 +6277,10 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
|
||||
String[] aliases = new String[property.getColumnSpan()];
|
||||
String[] cols = new String[property.getColumnSpan()];
|
||||
int l = 0;
|
||||
for ( Selectable selectable: property.getSelectables() ) {
|
||||
Dialect dialect = getFactory().getJdbcServices().getDialect();
|
||||
aliases[l] = selectable.getAlias( dialect, property.getValue().getTable() );
|
||||
cols[l] = selectable.getText(dialect); // TODO: skip formulas?
|
||||
l++;
|
||||
}
|
||||
|
||||
|
|
|
@ -7,10 +7,11 @@
|
|||
package org.hibernate.persister.entity;
|
||||
|
||||
|
||||
import org.hibernate.id.PostInsertIdentityPersister;
|
||||
|
||||
/**
|
||||
* @deprecated Just used to singly extend all the deprecated entity persister roles
|
||||
*/
|
||||
@Deprecated
|
||||
public interface DeprecatedEntityStuff
|
||||
extends OuterJoinLoadable, UniqueKeyLoadable, Loadable, Lockable, Queryable {
|
||||
public interface DeprecatedEntityStuff extends Loadable, Lockable, Queryable, PostInsertIdentityPersister {
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
|||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.internal.SqlFragmentPredicate;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.sql.ast.SqlAstJoinType;
|
||||
import org.hibernate.sql.ast.tree.from.NamedTableReference;
|
||||
|
@ -73,7 +72,6 @@ import static org.hibernate.internal.util.collections.ArrayHelper.to2DStringArra
|
|||
import static org.hibernate.internal.util.collections.ArrayHelper.toIntArray;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toStringArray;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.linkedMapOfSize;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.mapOfSize;
|
||||
import static org.hibernate.jdbc.Expectations.createExpectation;
|
||||
import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.buildEncapsulatedCompositeIdentifierMapping;
|
||||
import static org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper.buildNonEncapsulatedCompositeIdentifierMapping;
|
||||
|
@ -119,7 +117,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
// properties of this class, including inherited properties
|
||||
private final int[] naturalOrderPropertyTableNumbers;
|
||||
// private final int[] propertyTableNumbers;
|
||||
|
||||
// the closure of all properties in the entire hierarchy including
|
||||
// subclasses and superclasses of this class
|
||||
|
@ -128,12 +125,8 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
// the closure of all columns used by the entire hierarchy including
|
||||
// subclasses and superclasses of this class
|
||||
private final int[] subclassColumnTableNumberClosure;
|
||||
// private final int[] subclassFormulaTableNumberClosure;
|
||||
private final String[] subclassColumnClosure;
|
||||
|
||||
// private final boolean[] subclassTableSequentialSelect;
|
||||
// private final boolean[] subclassTableIsLazyClosure;
|
||||
private final boolean[] isInverseSubclassTable;
|
||||
private final boolean[] isNullableSubclassTable;
|
||||
|
||||
// subclass discrimination works by assigning particular
|
||||
|
@ -164,19 +157,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
private final Map<String, Object> discriminatorValuesByTableName;
|
||||
private final Map<String, String> discriminatorColumnNameByTableName;
|
||||
private final Map<String, String> subclassNameByTableName;
|
||||
|
||||
//INITIALIZATION:
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public JoinedSubclassEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
final PersisterCreationContext creationContext) throws HibernateException {
|
||||
this( persistentClass,cacheAccessStrategy,naturalIdRegionAccessStrategy,
|
||||
(RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public JoinedSubclassEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
|
@ -313,17 +293,11 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
final ArrayList<String> subclassTableNames = new ArrayList<>();
|
||||
final ArrayList<Boolean> isConcretes = new ArrayList<>();
|
||||
// final ArrayList<Boolean> isDeferreds = new ArrayList<>();
|
||||
// final ArrayList<Boolean> isLazies = new ArrayList<>();
|
||||
final ArrayList<Boolean> isInverses = new ArrayList<>();
|
||||
final ArrayList<Boolean> isNullables = new ArrayList<>();
|
||||
|
||||
final ArrayList<String[]> allKeyColumns = new ArrayList<>();
|
||||
for ( Table table : persistentClass.getSubclassTableClosure() ) {
|
||||
isConcretes.add( persistentClass.isClassOrSuperclassTable( table ) );
|
||||
// isDeferreds.add( false );
|
||||
// isLazies.add( false );
|
||||
isInverses.add( false );
|
||||
isNullables.add( false );
|
||||
final String tableName = determineTableName( table );
|
||||
subclassTableNames.add( tableName );
|
||||
|
@ -339,10 +313,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
for ( Join join : persistentClass.getSubclassJoinClosure() ) {
|
||||
final Table joinTable = join.getTable();
|
||||
isConcretes.add( persistentClass.isClassOrSuperclassTable( joinTable ) );
|
||||
// isDeferreds.add( join.isSequentialSelect() );
|
||||
isInverses.add( join.isInverse() );
|
||||
isNullables.add( join.isOptional() );
|
||||
// isLazies.add( join.isLazy() );
|
||||
final String joinTableName = determineTableName( joinTable );
|
||||
subclassTableNames.add( joinTableName );
|
||||
final String[] key = new String[idColumnSpan];
|
||||
|
@ -356,9 +327,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
final String[] naturalOrderSubclassTableNameClosure = toStringArray( subclassTableNames );
|
||||
final String[][] naturalOrderSubclassTableKeyColumnClosure = to2DStringArray( allKeyColumns );
|
||||
isClassOrSuperclassTable = ArrayHelper.toBooleanArray( isConcretes );
|
||||
// subclassTableSequentialSelect = ArrayHelper.toBooleanArray( isDeferreds );
|
||||
// subclassTableIsLazyClosure = ArrayHelper.toBooleanArray( isLazies );
|
||||
isInverseSubclassTable = ArrayHelper.toBooleanArray( isInverses );
|
||||
isNullableSubclassTable = ArrayHelper.toBooleanArray( isNullables );
|
||||
|
||||
constraintOrderedTableNames = new String[naturalOrderSubclassTableNameClosure.length];
|
||||
|
@ -447,13 +415,11 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
// PROPERTIES
|
||||
final int hydrateSpan = getPropertySpan();
|
||||
naturalOrderPropertyTableNumbers = new int[hydrateSpan];
|
||||
// propertyTableNumbers = new int[hydrateSpan];
|
||||
final List<Property> propertyClosure = persistentClass.getPropertyClosure();
|
||||
for ( int i = 0; i < propertyClosure.size(); i++ ) {
|
||||
final String tableName =
|
||||
propertyClosure.get(i).getValue().getTable()
|
||||
.getQualifiedName( creationContext.getSqlStringGenerationContext() );
|
||||
// propertyTableNumbers[i] = getTableId( tableName, this.tableNames );
|
||||
naturalOrderPropertyTableNumbers[i] = getTableId( tableName, naturalOrderTableNames );
|
||||
}
|
||||
|
||||
|
@ -462,7 +428,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
//TODO: code duplication with SingleTableEntityPersister
|
||||
|
||||
final ArrayList<Integer> columnTableNumbers = new ArrayList<>();
|
||||
// final ArrayList<Integer> formulaTableNumbers = new ArrayList<>();
|
||||
final ArrayList<Integer> propTableNumbers = new ArrayList<>();
|
||||
final ArrayList<String> columns = new ArrayList<>();
|
||||
|
||||
|
@ -478,25 +443,18 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
Column column = (Column) selectable;
|
||||
columns.add( column.getQuotedName( dialect ) );
|
||||
}
|
||||
// else {
|
||||
// formulaTableNumbers.add( tableNumber );
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
subclassColumnTableNumberClosure = toIntArray( columnTableNumbers );
|
||||
subclassPropertyTableNumberClosure = toIntArray( propTableNumbers );
|
||||
// subclassFormulaTableNumberClosure = ArrayHelper.toIntArray( formulaTableNumbers );
|
||||
subclassColumnClosure = toStringArray( columns );
|
||||
|
||||
// SUBCLASSES
|
||||
|
||||
final int subclassSpan = persistentClass.getSubclassSpan() + 1;
|
||||
// subclassClosure = new String[subclassSpan];
|
||||
final int subclassSpanMinusOne = subclassSpan - 1;
|
||||
// subclassClosure[subclassSpanMinusOne] = getEntityName();
|
||||
if ( !persistentClass.isPolymorphic() ) {
|
||||
subclassNameByTableName = emptyMap();
|
||||
discriminatorValuesByTableName = emptyMap();
|
||||
discriminatorColumnNameByTableName = emptyMap();
|
||||
discriminatorValues = null;
|
||||
|
@ -509,7 +467,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
discriminatorValuesByTableName = linkedMapOfSize( subclassSpan + 1 );
|
||||
discriminatorColumnNameByTableName = linkedMapOfSize( subclassSpan + 1 );
|
||||
subclassNameByTableName = mapOfSize( subclassSpan + 1 );
|
||||
|
||||
final Table table = persistentClass.getTable();
|
||||
discriminatorValues = new String[subclassSpan];
|
||||
|
@ -528,9 +485,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
final List<Subclass> subclasses = persistentClass.getSubclasses();
|
||||
for ( int k = 0; k < subclasses.size(); k++ ) {
|
||||
final Subclass subclass = subclasses.get(k);
|
||||
// subclassClosure[k] = subclass.getEntityName();
|
||||
final Table subclassTable = subclass.getTable();
|
||||
subclassNameByTableName.put( subclassTable.getName(), subclass.getEntityName() );
|
||||
if ( persistentClass.isPolymorphic() ) {
|
||||
final Object discriminatorValue = explicitDiscriminatorColumnName != null
|
||||
? DiscriminatorHelper.getDiscriminatorValue( subclass )
|
||||
|
@ -756,7 +711,7 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getSubclassPropertyTableName(int i) {
|
||||
public String getAttributeMutationTableName(int i) {
|
||||
return subclassTableNameClosure[subclassPropertyTableNumberClosure[i]];
|
||||
}
|
||||
|
||||
|
@ -905,11 +860,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
return temp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fromTableFragment(String alias) {
|
||||
return getTableName() + ' ' + alias;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return tableNames[0];
|
||||
|
@ -940,11 +890,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
return tableKeyColumnReaders[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSubclassPropertyTableNumber(int i) {
|
||||
return subclassPropertyTableNumberClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTableSpan() {
|
||||
return tableSpan;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
package org.hibernate.persister.entity;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.type.Type;
|
||||
|
@ -115,4 +116,19 @@ public interface Loadable extends EntityPersister {
|
|||
* 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);
|
||||
|
||||
/**
|
||||
* May this (subclass closure) property be fetched using an SQL outerjoin?
|
||||
*/
|
||||
FetchMode getFetchMode(int i);
|
||||
|
||||
/**
|
||||
* Get the type of the numbered property of the class or a subclass.
|
||||
*/
|
||||
Type getSubclassPropertyType(int i);
|
||||
|
||||
/**
|
||||
* Get the column names for the given property path
|
||||
*/
|
||||
String[] getPropertyColumnNames(String propertyPath);
|
||||
}
|
||||
|
|
|
@ -1,106 +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.FetchMode;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* A {@link EntityPersister} that may be loaded by outer join using
|
||||
* and may be an element of a one-to-many association.
|
||||
*
|
||||
* @author Gavin King
|
||||
*
|
||||
* @deprecated Use {@link EntityMappingType}
|
||||
*/
|
||||
@Deprecated(since = "6", forRemoval = true)
|
||||
public interface OuterJoinLoadable extends Loadable, Joinable {
|
||||
|
||||
/**
|
||||
* Generate a list of collection index, key and element columns
|
||||
*/
|
||||
String selectFragment(String alias, String suffix);
|
||||
/**
|
||||
* How many properties are there, for this class and all subclasses?
|
||||
*/
|
||||
int countSubclassProperties();
|
||||
|
||||
/**
|
||||
* May this (subclass closure) property be fetched using an SQL outerjoin?
|
||||
*/
|
||||
FetchMode getFetchMode(int i);
|
||||
/**
|
||||
* Get the cascade style of this (subclass closure) property
|
||||
*/
|
||||
CascadeStyle getCascadeStyle(int i);
|
||||
|
||||
/**
|
||||
* Is this property defined on a subclass of the mapped class.
|
||||
*/
|
||||
boolean isDefinedOnSubclass(int i);
|
||||
|
||||
/**
|
||||
* Get the type of the numbered property of the class or a subclass.
|
||||
*/
|
||||
Type getSubclassPropertyType(int i);
|
||||
|
||||
/**
|
||||
* Get the name of the numbered property of the class or a subclass.
|
||||
*/
|
||||
String getSubclassPropertyName(int i);
|
||||
|
||||
/**
|
||||
* Is the numbered property of the class of subclass nullable?
|
||||
*/
|
||||
boolean isSubclassPropertyNullable(int i);
|
||||
|
||||
/**
|
||||
* Return the column names used to persist the numbered property of the
|
||||
* class or a subclass.
|
||||
*/
|
||||
String[] getSubclassPropertyColumnNames(int i);
|
||||
|
||||
/**
|
||||
* Return the table name used to persist the numbered property of the
|
||||
* class or a subclass.
|
||||
*/
|
||||
String getSubclassPropertyTableName(int i);
|
||||
|
||||
/**
|
||||
* The name of the table to use when performing mutations (INSERT,UPDATE,DELETE)
|
||||
* for the given attribute
|
||||
*/
|
||||
default String getAttributeMutationTableName(int attributeIndex) {
|
||||
return getSubclassPropertyTableName( attributeIndex );
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the number of a property of a subclass, and a table alias,
|
||||
* return the aliased column names.
|
||||
*/
|
||||
String[] toColumns(String name, int i);
|
||||
|
||||
/**
|
||||
* Get the main from table fragment, given a query alias.
|
||||
*/
|
||||
String fromTableFragment(String alias);
|
||||
|
||||
/**
|
||||
* Get the column names for the given property path
|
||||
*/
|
||||
String[] getPropertyColumnNames(String propertyPath);
|
||||
/**
|
||||
* Get the table name for the given property path
|
||||
*/
|
||||
String getPropertyTableName(String propertyName);
|
||||
|
||||
EntityType getEntityType();
|
||||
|
||||
}
|
|
@ -34,7 +34,6 @@ import org.hibernate.mapping.Value;
|
|||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||
import org.hibernate.sql.ast.tree.from.NamedTableReference;
|
||||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
@ -86,10 +85,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
private final String[] subclassClosure;
|
||||
|
||||
private final String[] subclassTableNameClosure;
|
||||
// private final boolean[] subclassTableIsLazyClosure;
|
||||
private final boolean[] isInverseSubclassTable;
|
||||
private final boolean[] isNullableSubclassTable;
|
||||
// private final boolean[] subclassTableSequentialSelect;
|
||||
private final String[][] subclassTableKeyColumnClosure;
|
||||
private final boolean[] isClassOrSuperclassTable;
|
||||
private final boolean[] isClassOrSuperclassJoin;
|
||||
|
@ -116,15 +112,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
private final String[] constraintOrderedTableNames;
|
||||
private final String[][] constraintOrderedKeyColumnNames;
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public SingleTableEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
final PersisterCreationContext creationContext) throws HibernateException {
|
||||
this( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public SingleTableEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
|
@ -223,33 +210,20 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
spaces = ArrayHelper.join( qualifiedTableNames, toStringArray( persistentClass.getSynchronizedTables() ) );
|
||||
|
||||
// final boolean lazyAvailable = isInstrumented();
|
||||
|
||||
final ArrayList<String> subclassTables = new ArrayList<>();
|
||||
final ArrayList<String[]> joinKeyColumns = new ArrayList<>();
|
||||
final ArrayList<Boolean> isConcretes = new ArrayList<>();
|
||||
final ArrayList<Boolean> isClassOrSuperclassJoins = new ArrayList<>();
|
||||
// final ArrayList<Boolean> isDeferreds = new ArrayList<>();
|
||||
final ArrayList<Boolean> isInverses = new ArrayList<>();
|
||||
final ArrayList<Boolean> isNullables = new ArrayList<>();
|
||||
// final ArrayList<Boolean> isLazies = new ArrayList<>();
|
||||
subclassTables.add( qualifiedTableNames[0] );
|
||||
joinKeyColumns.add( getIdentifierColumnNames() );
|
||||
isConcretes.add( true );
|
||||
isClassOrSuperclassJoins.add( true );
|
||||
// isDeferreds.add( false );
|
||||
isInverses.add( false );
|
||||
isNullables.add( false );
|
||||
// isLazies.add( false );
|
||||
for ( Join join : persistentClass.getSubclassJoinClosure() ) {
|
||||
isConcretes.add( persistentClass.isClassOrSuperclassTable( join.getTable() ) );
|
||||
isClassOrSuperclassJoins.add( persistentClass.isClassOrSuperclassJoin( join ) );
|
||||
isInverses.add( join.isInverse() );
|
||||
isNullables.add( join.isOptional() );
|
||||
// isLazies.add( lazyAvailable && join.isLazy() );
|
||||
|
||||
// boolean isDeferred = join.isSequentialSelect() && !persistentClass.isClassOrSuperclassJoin( join );
|
||||
// isDeferreds.add( isDeferred );
|
||||
|
||||
final String joinTableName = determineTableName( join.getTable() );
|
||||
subclassTables.add( joinTableName );
|
||||
|
@ -262,13 +236,10 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
joinKeyColumns.add( keyCols );
|
||||
}
|
||||
|
||||
// subclassTableSequentialSelect = ArrayHelper.toBooleanArray( isDeferreds );
|
||||
subclassTableNameClosure = toStringArray( subclassTables );
|
||||
// subclassTableIsLazyClosure = ArrayHelper.toBooleanArray( isLazies );
|
||||
subclassTableKeyColumnClosure = to2DStringArray( joinKeyColumns );
|
||||
isClassOrSuperclassTable = toBooleanArray( isConcretes );
|
||||
isClassOrSuperclassJoin = toBooleanArray( isClassOrSuperclassJoins );
|
||||
isInverseSubclassTable = toBooleanArray( isInverses );
|
||||
isNullableSubclassTable = toBooleanArray( isNullables );
|
||||
|
||||
// DISCRIMINATOR
|
||||
|
@ -311,7 +282,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
discriminatorType = null;
|
||||
discriminatorValue = null;
|
||||
discriminatorSQLValue = null;
|
||||
// discriminatorFormula = null;
|
||||
discriminatorFormulaTemplate = null;
|
||||
}
|
||||
|
||||
|
@ -325,11 +295,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
//TODO: code duplication with JoinedSubclassEntityPersister
|
||||
|
||||
// final ArrayList<Integer> columnJoinNumbers = new ArrayList<>();
|
||||
// final ArrayList<Integer> formulaJoinedNumbers = new ArrayList<>();
|
||||
final ArrayList<Integer> propertyJoinNumbers = new ArrayList<>();
|
||||
|
||||
// final HashMap<String, Integer> propertyTableNumbersByNameAndSubclassLocal = new HashMap<>();
|
||||
final Map<Object, String> subclassesByDiscriminatorValueLocal = new HashMap<>();
|
||||
|
||||
for ( Property property : persistentClass.getSubclassPropertyClosure() ) {
|
||||
|
@ -512,26 +478,15 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
// Execute the SQL:
|
||||
|
||||
@Override
|
||||
public String fromTableFragment(String name) {
|
||||
return getTableName() + ' ' + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needsDiscriminator() {
|
||||
return forceDiscriminator || isInherited();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubclassPropertyTableName(int i) {
|
||||
public String getAttributeMutationTableName(int i) {
|
||||
return subclassTableNameClosure[subclassPropertyTableNumberClosure[i]];
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSubclassPropertyTableNumber(int i) {
|
||||
return subclassPropertyTableNumberClosure[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTableSpan() {
|
||||
return joinSpan;
|
||||
|
|
|
@ -47,7 +47,6 @@ import org.hibernate.metamodel.mapping.SelectableMapping;
|
|||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
import org.hibernate.sql.ast.spi.SqlAliasBase;
|
||||
import org.hibernate.sql.ast.spi.SqlAstCreationState;
|
||||
|
@ -93,18 +92,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
private final String[] constraintOrderedTableNames;
|
||||
private final String[][] constraintOrderedKeyColumnNames;
|
||||
|
||||
//INITIALIZATION:
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public UnionSubclassEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
final PersisterCreationContext creationContext) throws HibernateException {
|
||||
this( persistentClass,cacheAccessStrategy,naturalIdRegionAccessStrategy,
|
||||
(RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public UnionSubclassEntityPersister(
|
||||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
|
@ -354,25 +341,10 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
// Execute the SQL:
|
||||
|
||||
@Override
|
||||
public String fromTableFragment(String name) {
|
||||
return getTableName() + ' ' + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSubclassPropertyTableName(int i) {
|
||||
public String getAttributeMutationTableName(int i) {
|
||||
return getTableName();//ie. the subquery! yuck!
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAttributeMutationTableName(int attributeIndex) {
|
||||
return getRootTableName();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSubclassPropertyTableNumber(int i) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSubclassPropertyTableNumber(String propertyName) {
|
||||
return 0;
|
||||
|
|
|
@ -1,32 +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.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* An {@link EntityPersister} that can be loaded by a non-primary unique key.
|
||||
*
|
||||
* @author Gavin King
|
||||
*
|
||||
* @deprecated Use {@link org.hibernate.metamodel.mapping.EntityMappingType#loadByUniqueKey} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface UniqueKeyLoadable extends Loadable {
|
||||
/**
|
||||
* Load an instance of the persistent class, by a unique key other
|
||||
* than the primary key.
|
||||
*/
|
||||
Object loadByUniqueKey(String propertyName, Object uniqueKey, SharedSessionContractImplementor session);
|
||||
|
||||
|
||||
/**
|
||||
* Get the property number of the unique key property
|
||||
*/
|
||||
int getPropertyIndex(String propertyName);
|
||||
|
||||
}
|
|
@ -15,14 +15,12 @@ import org.hibernate.MappingException;
|
|||
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.internal.log.DeprecationLogger;
|
||||
import org.hibernate.mapping.Collection;
|
||||
import org.hibernate.mapping.PersistentClass;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.spi.PersisterClassResolver;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.persister.spi.PersisterFactory;
|
||||
import org.hibernate.service.spi.ServiceRegistryAwareService;
|
||||
import org.hibernate.service.spi.ServiceRegistryImplementor;
|
||||
|
@ -68,21 +66,7 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
EntityDataAccess entityCacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdCacheAccessStrategy,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
return createEntityPersister(
|
||||
persisterClassResolver.getEntityPersisterClass( entityBinding ),
|
||||
entityBinding,
|
||||
entityCacheAccessStrategy,
|
||||
naturalIdCacheAccessStrategy,
|
||||
creationContext
|
||||
);
|
||||
}
|
||||
|
||||
private EntityPersister createEntityPersister(
|
||||
Class<? extends EntityPersister> persisterClass,
|
||||
PersistentClass entityBinding,
|
||||
EntityDataAccess entityCacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdCacheAccessStrategy,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
final Class<? extends EntityPersister> persisterClass = persisterClassResolver.getEntityPersisterClass( entityBinding );
|
||||
final Constructor<? extends EntityPersister> constructor = resolveEntityPersisterConstructor( persisterClass );
|
||||
try {
|
||||
return constructor.newInstance( entityBinding, entityCacheAccessStrategy, naturalIdCacheAccessStrategy, creationContext );
|
||||
|
@ -125,28 +109,6 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
return persisterClass.getConstructor( ENTITY_PERSISTER_CONSTRUCTOR_ARGS );
|
||||
}
|
||||
catch (NoSuchMethodException noConstructorException) {
|
||||
// we could not find the constructor...
|
||||
//
|
||||
// until we drop support for the legacy constructor signature, see if they define a
|
||||
// constructor using that signature and use it if so
|
||||
try {
|
||||
final Constructor<? extends EntityPersister> constructor = persisterClass.getConstructor( LEGACY_ENTITY_PERSISTER_CONSTRUCTOR_ARGS );
|
||||
// they do use the legacy signature...
|
||||
|
||||
// warn them
|
||||
DeprecationLogger.DEPRECATION_LOGGER.debugf(
|
||||
"EntityPersister implementation defined constructor using legacy signature using `%s`; use `%s` instead",
|
||||
PersisterCreationContext.class.getName(),
|
||||
RuntimeModelCreationContext.class.getName()
|
||||
);
|
||||
|
||||
// but use it
|
||||
return constructor;
|
||||
}
|
||||
catch (NoSuchMethodException noLegacyConstructorException) {
|
||||
// fall through to below
|
||||
}
|
||||
|
||||
throw new MappingException( "Could not find appropriate constructor for " + persisterClass.getName(), noConstructorException );
|
||||
}
|
||||
|
||||
|
@ -157,19 +119,7 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
Collection collectionBinding,
|
||||
@Nullable CollectionDataAccess cacheAccessStrategy,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
return createCollectionPersister(
|
||||
persisterClassResolver.getCollectionPersisterClass( collectionBinding ),
|
||||
collectionBinding,
|
||||
cacheAccessStrategy,
|
||||
creationContext
|
||||
);
|
||||
}
|
||||
|
||||
private CollectionPersister createCollectionPersister(
|
||||
Class<? extends CollectionPersister> persisterClass,
|
||||
Collection collectionBinding,
|
||||
@Nullable CollectionDataAccess cacheAccessStrategy,
|
||||
@SuppressWarnings("deprecation") PersisterCreationContext creationContext) {
|
||||
final Class<? extends CollectionPersister> persisterClass = persisterClassResolver.getCollectionPersisterClass( collectionBinding );
|
||||
final Constructor<? extends CollectionPersister> constructor = resolveCollectionPersisterConstructor( persisterClass );
|
||||
try {
|
||||
return constructor.newInstance( collectionBinding, cacheAccessStrategy, creationContext );
|
||||
|
@ -178,7 +128,7 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
throw e;
|
||||
}
|
||||
catch (InvocationTargetException e) {
|
||||
Throwable target = e.getTargetException();
|
||||
final Throwable target = e.getTargetException();
|
||||
if ( target instanceof HibernateException ) {
|
||||
throw (HibernateException) target;
|
||||
}
|
||||
|
@ -203,90 +153,7 @@ public final class PersisterFactoryImpl implements PersisterFactory, ServiceRegi
|
|||
return persisterClass.getConstructor( COLLECTION_PERSISTER_CONSTRUCTOR_ARGS );
|
||||
}
|
||||
catch (NoSuchMethodException noConstructorException) {
|
||||
// we could not find the constructor...
|
||||
//
|
||||
// until we drop support for the legacy constructor signature, see if they define a
|
||||
// constructor using that signature and use it if so
|
||||
try {
|
||||
final Constructor<? extends CollectionPersister> constructor = persisterClass.getConstructor( LEGACY_COLLECTION_PERSISTER_CONSTRUCTOR_ARGS );
|
||||
// they do use the legacy signature...
|
||||
|
||||
// warn them
|
||||
DeprecationLogger.DEPRECATION_LOGGER.debugf(
|
||||
"CollectionPersister implementation defined constructor using legacy signature using `%s`; use `%s` instead",
|
||||
PersisterCreationContext.class.getName(),
|
||||
RuntimeModelCreationContext.class.getName()
|
||||
);
|
||||
|
||||
// but use it
|
||||
return constructor;
|
||||
}
|
||||
catch (NoSuchMethodException noLegacyConstructorException) {
|
||||
// fall through to below
|
||||
}
|
||||
|
||||
throw new MappingException( "Could not find appropriate constructor for " + persisterClass.getName(), noConstructorException );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The legacy constructor signature for {@link EntityPersister} implementations
|
||||
*
|
||||
* @deprecated use {@link #ENTITY_PERSISTER_CONSTRUCTOR_ARGS} instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
private static final Class<?>[] LEGACY_ENTITY_PERSISTER_CONSTRUCTOR_ARGS = new Class[] {
|
||||
PersistentClass.class,
|
||||
EntityDataAccess.class,
|
||||
NaturalIdDataAccess.class,
|
||||
PersisterCreationContext.class
|
||||
};
|
||||
|
||||
@Override
|
||||
public EntityPersister createEntityPersister(
|
||||
PersistentClass entityBinding,
|
||||
EntityDataAccess entityCacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdCacheAccessStrategy,
|
||||
@SuppressWarnings("deprecation") PersisterCreationContext creationContext) {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.debugf(
|
||||
"Encountered use of deprecated `PersisterFactory#createEntityPersister` form accepting `%s`; use form accepting `%s` instead",
|
||||
PersisterCreationContext.class.getName(),
|
||||
RuntimeModelCreationContext.class.getName()
|
||||
);
|
||||
|
||||
return createEntityPersister(
|
||||
entityBinding,
|
||||
entityCacheAccessStrategy,
|
||||
naturalIdCacheAccessStrategy,
|
||||
(RuntimeModelCreationContext) creationContext
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The constructor signature for {@link CollectionPersister} implementations
|
||||
*
|
||||
* @deprecated use {@link #COLLECTION_PERSISTER_CONSTRUCTOR_ARGS} instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
private static final Class<?>[] LEGACY_COLLECTION_PERSISTER_CONSTRUCTOR_ARGS = new Class[] {
|
||||
Collection.class,
|
||||
CollectionDataAccess.class,
|
||||
PersisterCreationContext.class
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public CollectionPersister createCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
@SuppressWarnings("deprecation") PersisterCreationContext creationContext) throws HibernateException {
|
||||
DeprecationLogger.DEPRECATION_LOGGER.debugf(
|
||||
"Encountered use of deprecated `PersisterFactory#createCollectionPersister` form accepting `%s`; use form accepting `%s` instead",
|
||||
PersisterCreationContext.class.getName(),
|
||||
RuntimeModelCreationContext.class.getName()
|
||||
);
|
||||
|
||||
return createCollectionPersister( collectionBinding, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,39 +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.spi;
|
||||
|
||||
import org.hibernate.boot.spi.BootstrapContext;
|
||||
import org.hibernate.boot.spi.MetadataImplementor;
|
||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.type.descriptor.java.spi.JavaTypeRegistry;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
/**
|
||||
* "Parameter object" providing access to additional information that may be needed
|
||||
* in the creation of the persisters.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*
|
||||
* @deprecated Use {@link RuntimeModelCreationContext} instead
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PersisterCreationContext {
|
||||
SessionFactoryImplementor getSessionFactory();
|
||||
|
||||
BootstrapContext getBootstrapContext();
|
||||
|
||||
default TypeConfiguration getTypeConfiguration() {
|
||||
return getBootstrapContext().getTypeConfiguration();
|
||||
}
|
||||
|
||||
MetadataImplementor getMetadata();
|
||||
|
||||
default JavaTypeRegistry getJavaTypeRegistry() {
|
||||
return getTypeConfiguration().getJavaTypeRegistry();
|
||||
}
|
||||
}
|
|
@ -31,54 +31,11 @@ public interface PersisterFactory extends Service {
|
|||
* @param naturalIdCacheAccessStrategy The cache access strategy for the entity's natural-id cross-ref region
|
||||
* @param creationContext Access to additional information needed to create the EntityPersister
|
||||
*/
|
||||
default EntityPersister createEntityPersister(
|
||||
PersistentClass entityBinding,
|
||||
EntityDataAccess entityCacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdCacheAccessStrategy,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
// for now, to minimize impact on existing custom impls, default this form to delegate to the original
|
||||
return createEntityPersister(
|
||||
entityBinding,
|
||||
entityCacheAccessStrategy,
|
||||
naturalIdCacheAccessStrategy,
|
||||
(PersisterCreationContext) creationContext
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a collection persister instance.
|
||||
*
|
||||
* @param collectionBinding The mapping information describing the collection
|
||||
* @param cacheAccessStrategy The cache access strategy for the collection region
|
||||
* @param creationContext Access to additional information needed to create an EntityPersister
|
||||
*/
|
||||
default CollectionPersister createCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
// for now, to minimize impact on existing custom impls, default this form to delegate to the original
|
||||
return createCollectionPersister( collectionBinding, cacheAccessStrategy, (PersisterCreationContext) creationContext );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an entity persister instance.
|
||||
*
|
||||
* @param entityBinding The mapping information describing the entity
|
||||
* @param entityCacheAccessStrategy The cache access strategy for the entity region
|
||||
* @param naturalIdCacheAccessStrategy The cache access strategy for the entity's natural-id cross-ref region
|
||||
* @param creationContext Access to additional information needed to create an EntityPersister
|
||||
*
|
||||
* @return An appropriate entity persister instance.
|
||||
*
|
||||
* @deprecated use {@link #createEntityPersister(PersistentClass, EntityDataAccess, NaturalIdDataAccess, RuntimeModelCreationContext)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
EntityPersister createEntityPersister(
|
||||
PersistentClass entityBinding,
|
||||
EntityDataAccess entityCacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdCacheAccessStrategy,
|
||||
PersisterCreationContext creationContext) throws HibernateException;
|
||||
RuntimeModelCreationContext creationContext);
|
||||
|
||||
/**
|
||||
* Create a collection persister instance.
|
||||
|
@ -86,13 +43,9 @@ public interface PersisterFactory extends Service {
|
|||
* @param collectionBinding The mapping information describing the collection
|
||||
* @param cacheAccessStrategy The cache access strategy for the collection region
|
||||
* @param creationContext Access to additional information needed to create an EntityPersister
|
||||
*
|
||||
* @deprecated use {@link #createCollectionPersister(Collection, CollectionDataAccess, RuntimeModelCreationContext)}
|
||||
* instead
|
||||
*/
|
||||
@Deprecated(since = "6.0")
|
||||
CollectionPersister createCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
PersisterCreationContext creationContext);
|
||||
RuntimeModelCreationContext creationContext);
|
||||
}
|
||||
|
|
|
@ -258,8 +258,9 @@ public class ResultSetMappingImpl implements ResultSetMapping {
|
|||
if ( polymorphic && ( legacyFetchBuilders == null || legacyFetchBuilders.isEmpty() )
|
||||
&& !entityResult.hasJoinFetches() ) {
|
||||
final Set<String> aliases = new TreeSet<>( String.CASE_INSENSITIVE_ORDER );
|
||||
final AbstractEntityPersister entityPersister = (AbstractEntityPersister) entityResult.getReferencedMappingContainer()
|
||||
.getEntityPersister();
|
||||
final AbstractEntityPersister entityPersister = (AbstractEntityPersister)
|
||||
entityResult.getReferencedMappingContainer()
|
||||
.getEntityPersister();
|
||||
for ( String[] columns : entityPersister.getContraintOrderedTableKeyColumnClosure() ) {
|
||||
addColumns( aliases, knownDuplicateAliases, columns );
|
||||
}
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.hibernate.mapping.Value;
|
|||
import org.hibernate.metamodel.mapping.EntityMappingType;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.tuple.IdentifierProperty;
|
||||
import org.hibernate.tuple.NonIdentifierAttribute;
|
||||
import org.hibernate.tuple.PropertyFactory;
|
||||
|
@ -62,7 +61,6 @@ import static org.hibernate.internal.CoreLogging.messageLogger;
|
|||
import static org.hibernate.internal.util.ReflectHelper.isAbstractClass;
|
||||
import static org.hibernate.internal.util.ReflectHelper.isFinalClass;
|
||||
import static org.hibernate.internal.util.collections.ArrayHelper.toIntArray;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.toSmallMap;
|
||||
import static org.hibernate.internal.util.collections.CollectionHelper.toSmallSet;
|
||||
|
||||
/**
|
||||
|
@ -141,20 +139,12 @@ public class EntityMetamodel implements Serializable {
|
|||
private final boolean inherited;
|
||||
private final boolean hasSubclasses;
|
||||
private final Set<String> subclassEntityNames;
|
||||
private final Map<Class<?>,String> entityNameByInheritanceClassMap;
|
||||
// private final Map<Class<?>,String> entityNameByInheritanceClassMap;
|
||||
|
||||
private final BeforeExecutionGenerator versionGenerator;
|
||||
|
||||
private final BytecodeEnhancementMetadata bytecodeEnhancementMetadata;
|
||||
|
||||
@Deprecated(since = "6.0")
|
||||
public EntityMetamodel(
|
||||
PersistentClass persistentClass,
|
||||
EntityPersister persister,
|
||||
PersisterCreationContext creationContext) {
|
||||
this( persistentClass, persister, (RuntimeModelCreationContext) creationContext );
|
||||
}
|
||||
|
||||
public EntityMetamodel(
|
||||
PersistentClass persistentClass,
|
||||
EntityPersister persister,
|
||||
|
@ -186,7 +176,7 @@ public class EntityMetamodel implements Serializable {
|
|||
final Set<String> idAttributeNames;
|
||||
|
||||
if ( identifierMapperComponent != null ) {
|
||||
nonAggregatedCidMapper = (CompositeType) identifierMapperComponent.getType();
|
||||
nonAggregatedCidMapper = identifierMapperComponent.getType();
|
||||
idAttributeNames = new HashSet<>( );
|
||||
for ( Property property : identifierMapperComponent.getProperties() ) {
|
||||
idAttributeNames.add( property.getName() );
|
||||
|
@ -469,14 +459,14 @@ public class EntityMetamodel implements Serializable {
|
|||
}
|
||||
subclassEntityNames = toSmallSet( subclassEntityNamesLocal );
|
||||
|
||||
HashMap<Class<?>, String> entityNameByInheritanceClassMapLocal = new HashMap<>();
|
||||
if ( persistentClass.hasPojoRepresentation() ) {
|
||||
entityNameByInheritanceClassMapLocal.put( persistentClass.getMappedClass(), persistentClass.getEntityName() );
|
||||
for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
entityNameByInheritanceClassMapLocal.put( subclass.getMappedClass(), subclass.getEntityName() );
|
||||
}
|
||||
}
|
||||
entityNameByInheritanceClassMap = toSmallMap( entityNameByInheritanceClassMapLocal );
|
||||
// HashMap<Class<?>, String> entityNameByInheritanceClassMapLocal = new HashMap<>();
|
||||
// if ( persistentClass.hasPojoRepresentation() ) {
|
||||
// entityNameByInheritanceClassMapLocal.put( persistentClass.getMappedClass(), persistentClass.getEntityName() );
|
||||
// for ( Subclass subclass : persistentClass.getSubclasses() ) {
|
||||
// entityNameByInheritanceClassMapLocal.put( subclass.getMappedClass(), subclass.getEntityName() );
|
||||
// }
|
||||
// }
|
||||
// entityNameByInheritanceClassMap = toSmallMap( entityNameByInheritanceClassMapLocal );
|
||||
}
|
||||
|
||||
private void verifyNaturalIdProperty(Property property) {
|
||||
|
@ -770,15 +760,15 @@ public class EntityMetamodel implements Serializable {
|
|||
return isAbstract;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the entity-name mapped to the given class within our inheritance hierarchy, if any.
|
||||
*
|
||||
* @param inheritanceClass The class for which to resolve the entity-name.
|
||||
* @return The mapped entity-name, or null if no such mapping was found.
|
||||
*/
|
||||
public String findEntityNameByEntityClass(Class<?> inheritanceClass) {
|
||||
return entityNameByInheritanceClassMap.get( inheritanceClass );
|
||||
}
|
||||
// /**
|
||||
// * Return the entity-name mapped to the given class within our inheritance hierarchy, if any.
|
||||
// *
|
||||
// * @param inheritanceClass The class for which to resolve the entity-name.
|
||||
// * @return The mapped entity-name, or null if no such mapping was found.
|
||||
// */
|
||||
// public String findEntityNameByEntityClass(Class<?> inheritanceClass) {
|
||||
// return entityNameByInheritanceClassMap.get( inheritanceClass );
|
||||
// }
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
|||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.Joinable;
|
||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
||||
import org.hibernate.proxy.LazyInitializer;
|
||||
import org.hibernate.type.spi.TypeConfiguration;
|
||||
|
||||
|
@ -738,10 +737,9 @@ public abstract class EntityType extends AbstractType implements AssociationType
|
|||
Object key,
|
||||
SharedSessionContractImplementor session) throws HibernateException {
|
||||
final SessionFactoryImplementor factory = session.getFactory();
|
||||
final UniqueKeyLoadable persister = (UniqueKeyLoadable) factory
|
||||
.getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor( entityName );
|
||||
EntityPersister persister =
|
||||
factory.getMappingMetamodel()
|
||||
.getEntityDescriptor( entityName );
|
||||
|
||||
//TODO: implement 2nd level caching?! natural id caching ?! proxies?!
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
|||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.UniqueKeyEntry;
|
||||
|
@ -66,7 +67,6 @@ import org.hibernate.persister.entity.mutation.EntityTableMapping;
|
|||
import org.hibernate.persister.entity.mutation.InsertCoordinator;
|
||||
import org.hibernate.persister.entity.mutation.UpdateCoordinator;
|
||||
import org.hibernate.persister.spi.PersisterClassResolver;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -102,7 +102,7 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
|
|||
final PersistentClass persistentClass,
|
||||
final EntityDataAccess cacheAccessStrategy,
|
||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
final PersisterCreationContext creationContext) {
|
||||
final RuntimeModelCreationContext creationContext) {
|
||||
throw new GoofyException(NoopEntityPersister.class);
|
||||
}
|
||||
|
||||
|
@ -868,7 +868,7 @@ public class GoofyPersisterClassProvider implements PersisterClassResolver {
|
|||
public NoopCollectionPersister(
|
||||
Collection collectionBinding,
|
||||
CollectionDataAccess cacheAccessStrategy,
|
||||
PersisterCreationContext creationContext) {
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
throw new GoofyException(NoopCollectionPersister.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ import org.hibernate.annotations.FetchMode;
|
|||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -172,7 +172,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
@ -180,7 +180,7 @@ public class BatchFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private AssociationType determineAssociationType(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
|
|
@ -14,7 +14,7 @@ import org.hibernate.annotations.FetchMode;
|
|||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -168,7 +168,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
@ -176,7 +176,7 @@ public class FetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private AssociationType determineAssociationType(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.hibernate.annotations.Proxy;
|
|||
import org.hibernate.engine.FetchStyle;
|
||||
import org.hibernate.engine.FetchTiming;
|
||||
import org.hibernate.metamodel.mapping.internal.FetchOptionsHelper;
|
||||
import org.hibernate.persister.entity.OuterJoinLoadable;
|
||||
import org.hibernate.persister.entity.Loadable;
|
||||
import org.hibernate.type.AssociationType;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
|
||||
|
@ -89,7 +89,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private org.hibernate.FetchMode determineFetchMode(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
@ -97,7 +97,7 @@ public class NoProxyFetchStrategyHelperTest extends BaseCoreFunctionalTestCase {
|
|||
}
|
||||
|
||||
private AssociationType determineAssociationType(Class<?> entityClass, String path) {
|
||||
OuterJoinLoadable entityPersister = (OuterJoinLoadable) sessionFactory().getRuntimeMetamodels()
|
||||
Loadable entityPersister = (Loadable) sessionFactory().getRuntimeMetamodels()
|
||||
.getMappingMetamodel()
|
||||
.getEntityDescriptor(entityClass.getName());
|
||||
int index = entityPersister.getPropertyIndex( path );
|
||||
|
|
|
@ -56,6 +56,7 @@ import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
|||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.orm.test.jpa.SettingsGenerator;
|
||||
import org.hibernate.persister.collection.CollectionPersister;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
|
@ -66,7 +67,6 @@ import org.hibernate.persister.entity.mutation.InsertCoordinator;
|
|||
import org.hibernate.persister.entity.mutation.UpdateCoordinator;
|
||||
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
|
||||
import org.hibernate.persister.spi.PersisterClassResolver;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -132,7 +132,7 @@ public class PersisterClassProviderTest {
|
|||
PersistentClass persistentClass,
|
||||
EntityDataAccess entityDataAccessstrategy,
|
||||
NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
PersisterCreationContext creationContext) {
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
throw new GoofyException();
|
||||
}
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ import org.hibernate.metamodel.mapping.NaturalIdMapping;
|
|||
import org.hibernate.metamodel.mapping.TableDetails;
|
||||
import org.hibernate.metamodel.model.domain.NavigableRole;
|
||||
import org.hibernate.metamodel.spi.EntityRepresentationStrategy;
|
||||
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.persister.entity.UniqueKeyEntry;
|
||||
import org.hibernate.persister.entity.mutation.DeleteCoordinator;
|
||||
import org.hibernate.persister.entity.mutation.EntityTableMapping;
|
||||
import org.hibernate.persister.entity.mutation.InsertCoordinator;
|
||||
import org.hibernate.persister.entity.mutation.UpdateCoordinator;
|
||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
|
||||
import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
|
||||
import org.hibernate.spi.NavigablePath;
|
||||
|
@ -95,7 +95,7 @@ public class CustomPersister implements EntityPersister {
|
|||
PersistentClass model,
|
||||
EntityDataAccess cacheAccessStrategy,
|
||||
NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||
PersisterCreationContext creationContext) {
|
||||
RuntimeModelCreationContext creationContext) {
|
||||
this.factory = creationContext.getSessionFactory();
|
||||
this.entityMetamodel = new EntityMetamodel( model, this, creationContext );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue