HHH-16407 - EntityPersister and CollectionPersister deprecations
This commit is contained in:
parent
867ce874e2
commit
fbe43b99fa
|
@ -243,7 +243,8 @@ public class PersistentBag<E> extends AbstractPersistentCollection<E> implements
|
||||||
@Override
|
@Override
|
||||||
public void initializeEmptyCollection(CollectionPersister persister) {
|
public void initializeEmptyCollection(CollectionPersister persister) {
|
||||||
assert bag == null;
|
assert bag == null;
|
||||||
bag = (List<E>) persister.getCollectionType().instantiate( 0 );
|
//noinspection unchecked
|
||||||
|
bag = (List<E>) persister.getCollectionSemantics().instantiateRaw( 0, persister );
|
||||||
endRead();
|
endRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,8 @@ public class PersistentList<E> extends AbstractPersistentCollection<E> implement
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void initializeEmptyCollection(CollectionPersister persister) {
|
public void initializeEmptyCollection(CollectionPersister persister) {
|
||||||
assert list == null;
|
assert list == null;
|
||||||
list = (List<E>) persister.getCollectionType().instantiate( 0 );
|
//noinspection unchecked
|
||||||
|
list = (List<E>) persister.getCollectionSemantics().instantiateRaw( 0, persister );
|
||||||
endRead();
|
endRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +122,7 @@ public class PersistentList<E> extends AbstractPersistentCollection<E> implement
|
||||||
final int size = array.length;
|
final int size = array.length;
|
||||||
|
|
||||||
assert list == null;
|
assert list == null;
|
||||||
this.list = (List<E>) persister.getCollectionType().instantiate( size );
|
list = (List<E>) persister.getCollectionSemantics().instantiateRaw( size, persister );
|
||||||
|
|
||||||
for ( Serializable arrayElement : array ) {
|
for ( Serializable arrayElement : array ) {
|
||||||
list.add( (E) persister.getElementType().assemble( arrayElement, getSession(), owner ) );
|
list.add( (E) persister.getElementType().assemble( arrayElement, getSession(), owner ) );
|
||||||
|
|
|
@ -94,7 +94,8 @@ public class PersistentMap<K,E> extends AbstractPersistentCollection<E> implemen
|
||||||
@Override
|
@Override
|
||||||
public void initializeEmptyCollection(CollectionPersister persister) {
|
public void initializeEmptyCollection(CollectionPersister persister) {
|
||||||
assert map == null;
|
assert map == null;
|
||||||
map = (Map<K,E>) persister.getCollectionType().instantiate( 0 );
|
//noinspection unchecked
|
||||||
|
map = (Map<K,E>) persister.getCollectionSemantics().instantiateRaw( 0, persister );
|
||||||
endRead();
|
endRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -96,7 +97,8 @@ public class PersistentSet<E> extends AbstractPersistentCollection<E> implements
|
||||||
@Override
|
@Override
|
||||||
public void initializeEmptyCollection(CollectionPersister persister) {
|
public void initializeEmptyCollection(CollectionPersister persister) {
|
||||||
assert set == null;
|
assert set == null;
|
||||||
set = (Set<E>) persister.getCollectionType().instantiate( 0 );
|
//noinspection unchecked
|
||||||
|
set = (Set<E>) persister.getCollectionSemantics().instantiateRaw( 0, persister );
|
||||||
endRead();
|
endRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,6 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
sessionFactoryOptions = options;
|
sessionFactoryOptions = options;
|
||||||
|
|
||||||
serviceRegistry = getServiceRegistry( options, this );
|
serviceRegistry = getServiceRegistry( options, this );
|
||||||
|
|
||||||
eventEngine = new EventEngine( bootMetamodel, this );
|
eventEngine = new EventEngine( bootMetamodel, this );
|
||||||
|
|
||||||
bootMetamodel.initSessionFactory( this );
|
bootMetamodel.initSessionFactory( this );
|
||||||
|
@ -262,21 +261,77 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
// registry here, and doing the engine later
|
// registry here, and doing the engine later
|
||||||
queryEngine = QueryEngine.from( this, bootMetamodel );
|
queryEngine = QueryEngine.from( this, bootMetamodel );
|
||||||
|
|
||||||
// this is where creation of the runtime metamodel happens
|
// create runtime metamodels (mapping and JPA)
|
||||||
final RuntimeMetamodelsImpl runtimeMetamodelsImpl = new RuntimeMetamodelsImpl();
|
final RuntimeMetamodelsImpl runtimeMetamodelsImpl = new RuntimeMetamodelsImpl();
|
||||||
runtimeMetamodels = runtimeMetamodelsImpl;
|
runtimeMetamodels = runtimeMetamodelsImpl;
|
||||||
new RuntimeModelCreationContext() {
|
final MappingMetamodelImpl mappingMetamodelImpl = new MappingMetamodelImpl( typeConfiguration, serviceRegistry );
|
||||||
final MappingMetamodelImpl mappingMetamodelImpl =
|
|
||||||
new MappingMetamodelImpl( typeConfiguration, serviceRegistry );
|
|
||||||
{
|
|
||||||
// need to set this before calling finishInitialization()
|
|
||||||
runtimeMetamodelsImpl.setMappingMetamodel( mappingMetamodelImpl );
|
runtimeMetamodelsImpl.setMappingMetamodel( mappingMetamodelImpl );
|
||||||
// because this calls back to the RuntimeMetamodelsImplementor
|
initializeMappingModel( mappingMetamodelImpl, bootstrapContext, bootMetamodel, options );
|
||||||
mappingMetamodelImpl.finishInitialization( this );
|
|
||||||
// need to set this after calling finishInitialization()
|
|
||||||
runtimeMetamodelsImpl.setJpaMetamodel( mappingMetamodelImpl.getJpaMetamodel() );
|
runtimeMetamodelsImpl.setJpaMetamodel( mappingMetamodelImpl.getJpaMetamodel() );
|
||||||
|
|
||||||
|
// this needs to happen after the mapping metamodel is
|
||||||
|
// completely built, since we need to use the persisters
|
||||||
|
fetchProfiles = getFetchProfiles( bootMetamodel, runtimeMetamodels.getMappingMetamodel() );
|
||||||
|
|
||||||
|
defaultSessionOpenOptions = createDefaultSessionOpenOptionsIfPossible();
|
||||||
|
temporarySessionOpenOptions = defaultSessionOpenOptions == null ? null : buildTemporarySessionOpenOptions();
|
||||||
|
defaultStatelessOptions = defaultSessionOpenOptions == null ? null : withStatelessOptions();
|
||||||
|
fastSessionServices = new FastSessionServices( this );
|
||||||
|
wrapperOptions = new SessionFactoryBasedWrapperOptions( this );
|
||||||
|
|
||||||
|
currentSessionContext = buildCurrentSessionContext();
|
||||||
|
|
||||||
|
// re-scope the TypeConfiguration to this SessionFactory,
|
||||||
|
// now that we are (almost) fully-initialized ... note,
|
||||||
|
// we could have done this earlier, but then it's hard to
|
||||||
|
// really know or control who's calling back to us while
|
||||||
|
// we're in an incompletely-initialized state
|
||||||
|
typeConfiguration.scope( this );
|
||||||
|
|
||||||
|
observer.sessionFactoryCreated( this );
|
||||||
|
|
||||||
|
// As last operation, delete all caches from ReflectionManager
|
||||||
|
// (not modelled as a listener as we want this to be last)
|
||||||
|
bootstrapContext.getReflectionManager().reset();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch ( Exception e ) {
|
||||||
|
disintegrate( e, integratorObserver );
|
||||||
|
|
||||||
|
try {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
catch (Exception closeException) {
|
||||||
|
LOG.debugf( "Eating error closing the SessionFactory after a failed attempt to start it" );
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG.debug( "Instantiated SessionFactory" );
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initializeMappingModel(
|
||||||
|
MappingMetamodelImpl mappingMetamodelImpl,
|
||||||
|
BootstrapContext bootstrapContext,
|
||||||
|
MetadataImplementor bootMetamodel,
|
||||||
|
SessionFactoryOptions options) {
|
||||||
|
final TypeConfiguration typeConfiguration = mappingMetamodelImpl.getTypeConfiguration();
|
||||||
|
mappingMetamodelImpl.finishInitialization( runtimeModelCreationContext(
|
||||||
|
bootstrapContext,
|
||||||
|
bootMetamodel,
|
||||||
|
mappingMetamodelImpl,
|
||||||
|
typeConfiguration,
|
||||||
|
options
|
||||||
|
) );
|
||||||
|
}
|
||||||
|
|
||||||
|
private RuntimeModelCreationContext runtimeModelCreationContext(
|
||||||
|
BootstrapContext bootstrapContext,
|
||||||
|
MetadataImplementor bootMetamodel,
|
||||||
|
MappingMetamodelImplementor mappingMetamodel,
|
||||||
|
TypeConfiguration typeConfiguration,
|
||||||
|
SessionFactoryOptions options) {
|
||||||
|
return new RuntimeModelCreationContext() {
|
||||||
@Override
|
@Override
|
||||||
public BootstrapContext getBootstrapContext() {
|
public BootstrapContext getBootstrapContext() {
|
||||||
return bootstrapContext;
|
return bootstrapContext;
|
||||||
|
@ -295,7 +350,7 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MappingMetamodelImplementor getDomainModel() {
|
public MappingMetamodelImplementor getDomainModel() {
|
||||||
return mappingMetamodelImpl;
|
return mappingMetamodel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -343,46 +398,6 @@ public class SessionFactoryImpl extends QueryParameterBindingTypeResolverImpl im
|
||||||
return serviceRegistry;
|
return serviceRegistry;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// this needs to happen after the mapping metamodel is
|
|
||||||
// completely built, since we need to use the persisters
|
|
||||||
fetchProfiles = getFetchProfiles( bootMetamodel, runtimeMetamodels.getMappingMetamodel() );
|
|
||||||
|
|
||||||
defaultSessionOpenOptions = createDefaultSessionOpenOptionsIfPossible();
|
|
||||||
temporarySessionOpenOptions = defaultSessionOpenOptions == null ? null : buildTemporarySessionOpenOptions();
|
|
||||||
defaultStatelessOptions = defaultSessionOpenOptions == null ? null : withStatelessOptions();
|
|
||||||
fastSessionServices = new FastSessionServices( this );
|
|
||||||
wrapperOptions = new SessionFactoryBasedWrapperOptions( this );
|
|
||||||
|
|
||||||
currentSessionContext = buildCurrentSessionContext();
|
|
||||||
|
|
||||||
// re-scope the TypeConfiguration to this SessionFactory,
|
|
||||||
// now that we are (almost) fully-initialized ... note,
|
|
||||||
// we could have done this earlier, but then it's hard to
|
|
||||||
// really know or control who's calling back to us while
|
|
||||||
// we're in an incompletely-initialized state
|
|
||||||
typeConfiguration.scope( this );
|
|
||||||
|
|
||||||
observer.sessionFactoryCreated( this );
|
|
||||||
|
|
||||||
// As last operation, delete all caches from ReflectionManager
|
|
||||||
// (not modelled as a listener as we want this to be last)
|
|
||||||
bootstrapContext.getReflectionManager().reset();
|
|
||||||
|
|
||||||
}
|
|
||||||
catch ( Exception e ) {
|
|
||||||
disintegrate( e, integratorObserver );
|
|
||||||
|
|
||||||
try {
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
catch (Exception closeException) {
|
|
||||||
LOG.debugf( "Eating error closing the SessionFactory after a failed attempt to start it" );
|
|
||||||
}
|
|
||||||
throw e;
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG.debug( "Instantiated SessionFactory" );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, Generator> createGenerators(
|
private static Map<String, Generator> createGenerators(
|
||||||
|
|
|
@ -44,6 +44,20 @@ public class CollectionElementLoaderByIndex implements Loader {
|
||||||
|
|
||||||
private final int keyJdbcCount;
|
private final int keyJdbcCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shortened form of {@link #CollectionElementLoaderByIndex(PluralAttributeMapping, int, LoadQueryInfluencers, SessionFactoryImplementor)}
|
||||||
|
* which applied the collection mapping's {@linkplain PluralAttributeMapping.IndexMetadata#getListIndexBase()}
|
||||||
|
*/
|
||||||
|
public CollectionElementLoaderByIndex(
|
||||||
|
PluralAttributeMapping attributeMapping,
|
||||||
|
LoadQueryInfluencers influencers,
|
||||||
|
SessionFactoryImplementor sessionFactory) {
|
||||||
|
this( attributeMapping, attributeMapping.getIndexMetadata().getListIndexBase(), influencers, sessionFactory );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param baseIndex A base value to apply to the relational index values processed on {@link #incrementIndexByBase}
|
||||||
|
*/
|
||||||
public CollectionElementLoaderByIndex(
|
public CollectionElementLoaderByIndex(
|
||||||
PluralAttributeMapping attributeMapping,
|
PluralAttributeMapping attributeMapping,
|
||||||
int baseIndex,
|
int baseIndex,
|
||||||
|
@ -144,11 +158,20 @@ public class CollectionElementLoaderByIndex implements Loader {
|
||||||
return list.get( 0 );
|
return list.get( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the index being loaded by for a List and the mapping specified a
|
||||||
|
* {@linkplain org.hibernate.annotations.ListIndexBase base-index}, this will return
|
||||||
|
* the passed {@code index} value incremented by the base. Otherwise, the passed {@code index}
|
||||||
|
* is returned.
|
||||||
|
*
|
||||||
|
* @param index The relational index value; specifically without any mapped base applied
|
||||||
|
*
|
||||||
|
* @return The appropriately incremented base
|
||||||
|
*/
|
||||||
protected Object incrementIndexByBase(Object index) {
|
protected Object incrementIndexByBase(Object index) {
|
||||||
if ( baseIndex != 0 ) {
|
if ( baseIndex > 0 ) {
|
||||||
index = (Integer) index + baseIndex;
|
return (Integer) index + baseIndex;
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,30 +27,30 @@ public enum CollectionClassification {
|
||||||
* An Object or primitive array. Roughly follows the semantics
|
* An Object or primitive array. Roughly follows the semantics
|
||||||
* of {@link #LIST}
|
* of {@link #LIST}
|
||||||
*/
|
*/
|
||||||
ARRAY( PluralAttribute.CollectionType.COLLECTION ),
|
ARRAY( PluralAttribute.CollectionType.COLLECTION, true ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A non-unique, unordered collection. Represented
|
* A non-unique, unordered collection. Represented
|
||||||
* as {@link java.util.Collection} or {@link java.util.List}
|
* as {@link java.util.Collection} or {@link java.util.List}
|
||||||
*/
|
*/
|
||||||
BAG( PluralAttribute.CollectionType.COLLECTION ),
|
BAG( PluralAttribute.CollectionType.COLLECTION, false ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link #BAG} with a generated id for each element
|
* A {@link #BAG} with a generated id for each element
|
||||||
*/
|
*/
|
||||||
ID_BAG( PluralAttribute.CollectionType.COLLECTION ),
|
ID_BAG( PluralAttribute.CollectionType.COLLECTION, false ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A non-unique, ordered collection following the requirements of {@link java.util.List}
|
* A non-unique, ordered collection following the requirements of {@link java.util.List}
|
||||||
*
|
*
|
||||||
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_LIST_SEMANTICS
|
* @see org.hibernate.cfg.AvailableSettings#DEFAULT_LIST_SEMANTICS
|
||||||
*/
|
*/
|
||||||
LIST( PluralAttribute.CollectionType.LIST ),
|
LIST( PluralAttribute.CollectionType.LIST, true ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A unique, unordered collection following the requirements of {@link java.util.Set}
|
* A unique, unordered collection following the requirements of {@link java.util.Set}
|
||||||
*/
|
*/
|
||||||
SET( PluralAttribute.CollectionType.SET ),
|
SET( PluralAttribute.CollectionType.SET, false ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sorted {@link #SET} using either natural sorting of the elements or a
|
* A sorted {@link #SET} using either natural sorting of the elements or a
|
||||||
|
@ -60,7 +60,7 @@ public enum CollectionClassification {
|
||||||
* @see org.hibernate.annotations.SortNatural
|
* @see org.hibernate.annotations.SortNatural
|
||||||
* @see org.hibernate.annotations.SortComparator
|
* @see org.hibernate.annotations.SortComparator
|
||||||
*/
|
*/
|
||||||
SORTED_SET( PluralAttribute.CollectionType.SET ),
|
SORTED_SET( PluralAttribute.CollectionType.SET, false ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link #SET} that is ordered using an order-by fragment
|
* A {@link #SET} that is ordered using an order-by fragment
|
||||||
|
@ -71,12 +71,12 @@ public enum CollectionClassification {
|
||||||
* @see jakarta.persistence.OrderBy
|
* @see jakarta.persistence.OrderBy
|
||||||
* @see org.hibernate.annotations.OrderBy
|
* @see org.hibernate.annotations.OrderBy
|
||||||
*/
|
*/
|
||||||
ORDERED_SET( PluralAttribute.CollectionType.SET ),
|
ORDERED_SET( PluralAttribute.CollectionType.SET, false ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection following the semantics of {@link java.util.Map}
|
* A collection following the semantics of {@link java.util.Map}
|
||||||
*/
|
*/
|
||||||
MAP( PluralAttribute.CollectionType.MAP ),
|
MAP( PluralAttribute.CollectionType.MAP, true ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A sorted {@link #MAP} using either natural sorting of the keys or a
|
* A sorted {@link #MAP} using either natural sorting of the keys or a
|
||||||
|
@ -86,7 +86,7 @@ public enum CollectionClassification {
|
||||||
* @see org.hibernate.annotations.SortNatural
|
* @see org.hibernate.annotations.SortNatural
|
||||||
* @see org.hibernate.annotations.SortComparator
|
* @see org.hibernate.annotations.SortComparator
|
||||||
*/
|
*/
|
||||||
SORTED_MAP( PluralAttribute.CollectionType.MAP ),
|
SORTED_MAP( PluralAttribute.CollectionType.MAP, true ),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@link #MAP} that is ordered using an order-by fragment
|
* A {@link #MAP} that is ordered using an order-by fragment
|
||||||
|
@ -97,18 +97,29 @@ public enum CollectionClassification {
|
||||||
* @see jakarta.persistence.OrderBy
|
* @see jakarta.persistence.OrderBy
|
||||||
* @see org.hibernate.annotations.OrderBy
|
* @see org.hibernate.annotations.OrderBy
|
||||||
*/
|
*/
|
||||||
ORDERED_MAP( PluralAttribute.CollectionType.MAP );
|
ORDERED_MAP( PluralAttribute.CollectionType.MAP, true );
|
||||||
|
|
||||||
private final PluralAttribute.CollectionType jpaClassification;
|
private final PluralAttribute.CollectionType jpaClassification;
|
||||||
|
private final boolean isIndexed;
|
||||||
|
|
||||||
CollectionClassification(PluralAttribute.CollectionType jpaClassification) {
|
CollectionClassification(PluralAttribute.CollectionType jpaClassification, boolean isIndexed) {
|
||||||
this.jpaClassification = jpaClassification;
|
this.jpaClassification = jpaClassification;
|
||||||
|
this.isIndexed = isIndexed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluralAttribute.CollectionType toJpaClassification() {
|
public PluralAttribute.CollectionType toJpaClassification() {
|
||||||
return jpaClassification;
|
return jpaClassification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isIndexed() {
|
||||||
|
return isIndexed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRowUpdatePossible() {
|
||||||
|
// anything other than BAG and SET
|
||||||
|
return this != BAG && this != SET;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* One of:<ul>
|
* One of:<ul>
|
||||||
* <li>{@link org.hibernate.metamodel.CollectionClassification} instance</li>
|
* <li>{@link org.hibernate.metamodel.CollectionClassification} instance</li>
|
||||||
|
@ -174,9 +185,4 @@ public enum CollectionClassification {
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRowUpdatePossible() {
|
|
||||||
// anything other than BAG and SET
|
|
||||||
return this != BAG && this != SET;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import org.hibernate.Internal;
|
||||||
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
import org.hibernate.boot.jaxb.mapping.JaxbEntity;
|
||||||
import org.hibernate.engine.OptimisticLockStyle;
|
import org.hibernate.engine.OptimisticLockStyle;
|
||||||
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
import org.hibernate.engine.spi.LoadQueryInfluencers;
|
||||||
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.loader.ast.spi.Loadable;
|
import org.hibernate.loader.ast.spi.Loadable;
|
||||||
import org.hibernate.loader.ast.spi.MultiNaturalIdLoader;
|
import org.hibernate.loader.ast.spi.MultiNaturalIdLoader;
|
||||||
import org.hibernate.loader.ast.spi.NaturalIdLoader;
|
import org.hibernate.loader.ast.spi.NaturalIdLoader;
|
||||||
|
@ -458,6 +459,12 @@ public interface EntityMappingType
|
||||||
*/
|
*/
|
||||||
MultiNaturalIdLoader<?> getMultiNaturalIdLoader();
|
MultiNaturalIdLoader<?> getMultiNaturalIdLoader();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load an instance of the persistent class, by a unique key other
|
||||||
|
* than the primary key.
|
||||||
|
*/
|
||||||
|
Object loadByUniqueKey(String propertyName, Object uniqueKey, SharedSessionContractImplementor session);
|
||||||
|
|
||||||
|
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Loadable
|
// Loadable
|
||||||
|
|
|
@ -174,6 +174,7 @@ public class PluralAttributeMappingImpl
|
||||||
else {
|
else {
|
||||||
baseIndex = -1;
|
baseIndex = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
indexMetadata = new IndexMetadata() {
|
indexMetadata = new IndexMetadata() {
|
||||||
@Override
|
@Override
|
||||||
public CollectionPart getIndexDescriptor() {
|
public CollectionPart getIndexDescriptor() {
|
||||||
|
|
|
@ -7,18 +7,23 @@
|
||||||
package org.hibernate.metamodel.model.domain;
|
package org.hibernate.metamodel.model.domain;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import org.hibernate.spi.DotIdentifierSequence;
|
|
||||||
import org.hibernate.internal.util.StringHelper;
|
import org.hibernate.internal.util.StringHelper;
|
||||||
|
import org.hibernate.spi.DotIdentifierSequence;
|
||||||
import org.hibernate.spi.NavigablePath;
|
import org.hibernate.spi.NavigablePath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Poorly named.
|
* A compound path which represents a {@link org.hibernate.metamodel.mapping.ModelPart}
|
||||||
|
* and uniquely identifies it with the runtime metamodel.
|
||||||
|
* <p/>
|
||||||
|
* The {@linkplain #isRoot() root} will name either an
|
||||||
|
* {@linkplain org.hibernate.metamodel.MappingMetamodel#getEntityDescriptor entity} or
|
||||||
|
* {@linkplain org.hibernate.metamodel.MappingMetamodel#getCollectionDescriptor collection}
|
||||||
*
|
*
|
||||||
* Should have been named `org.hibernate.metamodel.model.mapping.MappingRole`
|
|
||||||
*
|
*
|
||||||
* Represents a compound path of `ModelPart` nodes rooted at an entity-name.
|
* @apiNote Poorly named. Should probably have been `org.hibernate.metamodel.model.mapping.MappingRole`;
|
||||||
|
* the term "navigable" here is meant to indicate that we could navigate to the specific
|
||||||
|
* {@link org.hibernate.metamodel.mapping.ModelPart} given the role.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
package org.hibernate.persister.collection;
|
package org.hibernate.persister.collection;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
@ -70,11 +69,11 @@ import org.hibernate.mapping.Column;
|
||||||
import org.hibernate.mapping.Formula;
|
import org.hibernate.mapping.Formula;
|
||||||
import org.hibernate.mapping.IdentifierCollection;
|
import org.hibernate.mapping.IdentifierCollection;
|
||||||
import org.hibernate.mapping.IndexedCollection;
|
import org.hibernate.mapping.IndexedCollection;
|
||||||
import org.hibernate.mapping.List;
|
|
||||||
import org.hibernate.mapping.Selectable;
|
import org.hibernate.mapping.Selectable;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.mapping.Value;
|
import org.hibernate.mapping.Value;
|
||||||
import org.hibernate.metadata.CollectionMetadata;
|
import org.hibernate.metadata.CollectionMetadata;
|
||||||
|
import org.hibernate.metamodel.CollectionClassification;
|
||||||
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
import org.hibernate.metamodel.mapping.EmbeddableValuedModelPart;
|
||||||
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
import org.hibernate.metamodel.mapping.ForeignKeyDescriptor;
|
||||||
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
import org.hibernate.metamodel.mapping.PluralAttributeMapping;
|
||||||
|
@ -146,11 +145,14 @@ import static org.hibernate.sql.model.ModelMutationLogging.MODEL_MUTATION_LOGGER
|
||||||
*/
|
*/
|
||||||
@Internal
|
@Internal
|
||||||
public abstract class AbstractCollectionPersister
|
public abstract class AbstractCollectionPersister
|
||||||
implements SQLLoadableCollection, PluralAttributeMappingImpl.Aware, CollectionMutationTarget, CollectionMetadata {
|
implements CollectionPersister, CollectionMutationTarget, PluralAttributeMappingImpl.Aware, DeprecatedCollectionStuff {
|
||||||
|
|
||||||
private final NavigableRole navigableRole;
|
private final NavigableRole navigableRole;
|
||||||
private final CollectionSemantics<?,?> collectionSemantics;
|
private final CollectionSemantics<?,?> collectionSemantics;
|
||||||
|
private final EntityPersister ownerPersister;
|
||||||
|
private final SessionFactoryImplementor factory;
|
||||||
|
|
||||||
|
protected final String qualifiedTableName;
|
||||||
private final CollectionTableMapping tableMapping;
|
private final CollectionTableMapping tableMapping;
|
||||||
|
|
||||||
private final String sqlSelectSizeString;
|
private final String sqlSelectSizeString;
|
||||||
|
@ -164,19 +166,11 @@ public abstract class AbstractCollectionPersister
|
||||||
private final boolean hasOrder;
|
private final boolean hasOrder;
|
||||||
private final boolean hasManyToManyOrder;
|
private final boolean hasManyToManyOrder;
|
||||||
|
|
||||||
private final int baseIndex;
|
|
||||||
|
|
||||||
private final String mappedByProperty;
|
private final String mappedByProperty;
|
||||||
|
|
||||||
protected final boolean indexContainsFormula;
|
protected final boolean indexContainsFormula;
|
||||||
protected final boolean elementIsPureFormula;
|
protected final boolean elementIsPureFormula;
|
||||||
|
|
||||||
// types
|
|
||||||
private final Type keyType;
|
|
||||||
private final Type indexType;
|
|
||||||
protected final Type elementType;
|
|
||||||
private final Type identifierType;
|
|
||||||
|
|
||||||
// columns
|
// columns
|
||||||
protected final String[] keyColumnNames;
|
protected final String[] keyColumnNames;
|
||||||
protected final String[] indexColumnNames;
|
protected final String[] indexColumnNames;
|
||||||
|
@ -192,21 +186,12 @@ public abstract class AbstractCollectionPersister
|
||||||
protected final String[] elementFormulas;
|
protected final String[] elementFormulas;
|
||||||
protected final boolean[] elementColumnIsGettable;
|
protected final boolean[] elementColumnIsGettable;
|
||||||
protected final boolean[] elementColumnIsSettable;
|
protected final boolean[] elementColumnIsSettable;
|
||||||
protected final String[] indexColumnAliases;
|
|
||||||
protected final String[] elementColumnAliases;
|
|
||||||
protected final String[] keyColumnAliases;
|
|
||||||
|
|
||||||
protected final String identifierColumnName;
|
protected final String identifierColumnName;
|
||||||
private final String identifierColumnAlias;
|
|
||||||
|
|
||||||
protected final String qualifiedTableName;
|
|
||||||
|
|
||||||
private final String queryLoaderName;
|
private final String queryLoaderName;
|
||||||
|
|
||||||
private final boolean isPrimitiveArray;
|
private final boolean isPrimitiveArray;
|
||||||
private final boolean isArray;
|
|
||||||
protected final boolean hasIndex;
|
|
||||||
protected final boolean hasIdentifier;
|
|
||||||
private final boolean isLazy;
|
private final boolean isLazy;
|
||||||
private final boolean isExtraLazy;
|
private final boolean isExtraLazy;
|
||||||
protected final boolean isInverse;
|
protected final boolean isInverse;
|
||||||
|
@ -219,17 +204,13 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
// extra information about the element type
|
// extra information about the element type
|
||||||
private final Class<?> elementClass;
|
private final Class<?> elementClass;
|
||||||
private final String entityName;
|
|
||||||
|
|
||||||
private final Dialect dialect;
|
private final Dialect dialect;
|
||||||
protected final SqlExceptionHelper sqlExceptionHelper;
|
protected final SqlExceptionHelper sqlExceptionHelper;
|
||||||
private final SessionFactoryImplementor factory;
|
|
||||||
private final EntityPersister ownerPersister;
|
|
||||||
private final BeforeExecutionGenerator identifierGenerator;
|
private final BeforeExecutionGenerator identifierGenerator;
|
||||||
private final PropertyMapping elementPropertyMapping;
|
private final PropertyMapping elementPropertyMapping;
|
||||||
private final EntityPersister elementPersister;
|
private final EntityPersister elementPersister;
|
||||||
private final CollectionDataAccess cacheAccessStrategy;
|
private final CollectionDataAccess cacheAccessStrategy;
|
||||||
private final CollectionType collectionType;
|
|
||||||
|
|
||||||
private final CacheEntryStructure cacheEntryStructure;
|
private final CacheEntryStructure cacheEntryStructure;
|
||||||
|
|
||||||
|
@ -244,8 +225,6 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
private final String[] spaces;
|
private final String[] spaces;
|
||||||
|
|
||||||
private final Map<String,String[]> collectionPropertyColumnAliases = new HashMap<>();
|
|
||||||
|
|
||||||
private final Comparator<?> comparator;
|
private final Comparator<?> comparator;
|
||||||
|
|
||||||
private CollectionLoader collectionLoader;
|
private CollectionLoader collectionLoader;
|
||||||
|
@ -267,10 +246,12 @@ public abstract class AbstractCollectionPersister
|
||||||
Collection collectionBootDescriptor,
|
Collection collectionBootDescriptor,
|
||||||
CollectionDataAccess cacheAccessStrategy,
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
||||||
|
|
||||||
final Value elementBootDescriptor = collectionBootDescriptor.getElement();
|
|
||||||
|
|
||||||
this.factory = creationContext.getSessionFactory();
|
this.factory = creationContext.getSessionFactory();
|
||||||
|
this.collectionSemantics = creationContext.getBootstrapContext()
|
||||||
|
.getMetadataBuildingOptions()
|
||||||
|
.getPersistentCollectionRepresentationResolver()
|
||||||
|
.resolveRepresentation( collectionBootDescriptor );
|
||||||
|
|
||||||
this.cacheAccessStrategy = cacheAccessStrategy;
|
this.cacheAccessStrategy = cacheAccessStrategy;
|
||||||
if ( creationContext.getSessionFactoryOptions().isStructuredCacheEntriesEnabled() ) {
|
if ( creationContext.getSessionFactoryOptions().isStructuredCacheEntriesEnabled() ) {
|
||||||
cacheEntryStructure = collectionBootDescriptor.isMap()
|
cacheEntryStructure = collectionBootDescriptor.isMap()
|
||||||
|
@ -285,19 +266,19 @@ public abstract class AbstractCollectionPersister
|
||||||
sqlExceptionHelper = creationContext.getJdbcServices().getSqlExceptionHelper();
|
sqlExceptionHelper = creationContext.getJdbcServices().getSqlExceptionHelper();
|
||||||
collectionType = collectionBootDescriptor.getCollectionType();
|
collectionType = collectionBootDescriptor.getCollectionType();
|
||||||
navigableRole = new NavigableRole( collectionBootDescriptor.getRole() );
|
navigableRole = new NavigableRole( collectionBootDescriptor.getRole() );
|
||||||
entityName = collectionBootDescriptor.getOwnerEntityName();
|
ownerPersister = creationContext.getDomainModel().getEntityDescriptor( collectionBootDescriptor.getOwnerEntityName() );
|
||||||
ownerPersister = creationContext.getDomainModel().getEntityDescriptor( entityName );
|
|
||||||
queryLoaderName = collectionBootDescriptor.getLoaderName();
|
queryLoaderName = collectionBootDescriptor.getLoaderName();
|
||||||
isMutable = collectionBootDescriptor.isMutable();
|
isMutable = collectionBootDescriptor.isMutable();
|
||||||
mappedByProperty = collectionBootDescriptor.getMappedByProperty();
|
mappedByProperty = collectionBootDescriptor.getMappedByProperty();
|
||||||
|
|
||||||
Table table = collectionBootDescriptor.getCollectionTable();
|
final Value elementBootDescriptor = collectionBootDescriptor.getElement();
|
||||||
|
final Table table = collectionBootDescriptor.getCollectionTable();
|
||||||
|
|
||||||
fetchMode = elementBootDescriptor.getFetchMode();
|
fetchMode = elementBootDescriptor.getFetchMode();
|
||||||
elementType = elementBootDescriptor.getType();
|
elementType = elementBootDescriptor.getType();
|
||||||
// isSet = collectionBinding.isSet();
|
// isSet = collectionBinding.isSet();
|
||||||
// isSorted = collectionBinding.isSorted();
|
// isSorted = collectionBinding.isSorted();
|
||||||
isPrimitiveArray = collectionBootDescriptor.isPrimitiveArray();
|
isPrimitiveArray = collectionBootDescriptor.isPrimitiveArray();
|
||||||
isArray = collectionBootDescriptor.isArray();
|
|
||||||
subselectLoadable = collectionBootDescriptor.isSubselectLoadable();
|
subselectLoadable = collectionBootDescriptor.isSubselectLoadable();
|
||||||
|
|
||||||
qualifiedTableName = determineTableName( table );
|
qualifiedTableName = determineTableName( table );
|
||||||
|
@ -420,7 +401,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
// INDEX AND ROW SELECT
|
// INDEX AND ROW SELECT
|
||||||
|
|
||||||
hasIndex = collectionBootDescriptor.isIndexed();
|
final boolean hasIndex = collectionBootDescriptor.isIndexed();
|
||||||
if ( hasIndex ) {
|
if ( hasIndex ) {
|
||||||
// NativeSQL: collect index column and auto-aliases
|
// NativeSQL: collect index column and auto-aliases
|
||||||
IndexedCollection indexedCollection = (IndexedCollection) collectionBootDescriptor;
|
IndexedCollection indexedCollection = (IndexedCollection) collectionBootDescriptor;
|
||||||
|
@ -469,10 +450,6 @@ public abstract class AbstractCollectionPersister
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
indexContainsFormula = hasFormula;
|
indexContainsFormula = hasFormula;
|
||||||
//noinspection ConstantConditions
|
|
||||||
baseIndex = indexedCollection.isList()
|
|
||||||
? ( (List) indexedCollection ).getBaseIndex()
|
|
||||||
: 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
indexContainsFormula = false;
|
indexContainsFormula = false;
|
||||||
|
@ -483,10 +460,9 @@ public abstract class AbstractCollectionPersister
|
||||||
indexType = null;
|
indexType = null;
|
||||||
indexColumnNames = null;
|
indexColumnNames = null;
|
||||||
indexColumnAliases = null;
|
indexColumnAliases = null;
|
||||||
baseIndex = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hasIdentifier = collectionBootDescriptor.isIdentified();
|
final boolean hasIdentifier = collectionBootDescriptor.isIdentified();
|
||||||
if ( hasIdentifier ) {
|
if ( hasIdentifier ) {
|
||||||
if ( collectionBootDescriptor.isOneToMany() ) {
|
if ( collectionBootDescriptor.isOneToMany() ) {
|
||||||
throw new MappingException( "one-to-many collections with identifiers are not supported" );
|
throw new MappingException( "one-to-many collections with identifiers are not supported" );
|
||||||
|
@ -588,11 +564,6 @@ public abstract class AbstractCollectionPersister
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// "mapping model"
|
// "mapping model"
|
||||||
|
|
||||||
this.collectionSemantics = creationContext.getBootstrapContext()
|
|
||||||
.getMetadataBuildingOptions()
|
|
||||||
.getPersistentCollectionRepresentationResolver()
|
|
||||||
.resolveRepresentation( collectionBootDescriptor );
|
|
||||||
|
|
||||||
if ( queryLoaderName != null ) {
|
if ( queryLoaderName != null ) {
|
||||||
final NamedQueryMemento namedQueryMemento = factory
|
final NamedQueryMemento namedQueryMemento = factory
|
||||||
.getQueryEngine()
|
.getQueryEngine()
|
||||||
|
@ -626,11 +597,6 @@ public abstract class AbstractCollectionPersister
|
||||||
return navigableRole;
|
return navigableRole;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRole() {
|
|
||||||
return navigableRole.getFullPath();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Comparator<?> getSortingComparator() {
|
public Comparator<?> getSortingComparator() {
|
||||||
return comparator;
|
return comparator;
|
||||||
|
@ -655,7 +621,6 @@ public abstract class AbstractCollectionPersister
|
||||||
if ( attributeMapping.getIndexDescriptor() != null ) {
|
if ( attributeMapping.getIndexDescriptor() != null ) {
|
||||||
collectionElementLoaderByIndex = new CollectionElementLoaderByIndex(
|
collectionElementLoaderByIndex = new CollectionElementLoaderByIndex(
|
||||||
attributeMapping,
|
attributeMapping,
|
||||||
baseIndex,
|
|
||||||
LoadQueryInfluencers.NONE,
|
LoadQueryInfluencers.NONE,
|
||||||
getFactory()
|
getFactory()
|
||||||
);
|
);
|
||||||
|
@ -793,11 +758,6 @@ public abstract class AbstractCollectionPersister
|
||||||
return cacheAccessStrategy != null;
|
return cacheAccessStrategy != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public CollectionType getCollectionType() {
|
|
||||||
return collectionType;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract RowMutationOperations getRowMutationOperations();
|
protected abstract RowMutationOperations getRowMutationOperations();
|
||||||
protected abstract RemoveCoordinator getRemoveCoordinator();
|
protected abstract RemoveCoordinator getRemoveCoordinator();
|
||||||
|
|
||||||
|
@ -839,21 +799,6 @@ public abstract class AbstractCollectionPersister
|
||||||
return hasWhere;
|
return hasWhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getKeyType() {
|
|
||||||
return keyType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getIndexType() {
|
|
||||||
return indexType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getElementType() {
|
|
||||||
return elementType;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the element class of an array, or null otherwise. needed by arrays
|
* Return the element class of an array, or null otherwise. needed by arrays
|
||||||
*/
|
*/
|
||||||
|
@ -868,14 +813,16 @@ public abstract class AbstractCollectionPersister
|
||||||
@Deprecated(forRemoval = true)
|
@Deprecated(forRemoval = true)
|
||||||
@Remove
|
@Remove
|
||||||
protected Object decrementIndexByBase(Object index) {
|
protected Object decrementIndexByBase(Object index) {
|
||||||
if ( baseIndex != 0 ) {
|
final int baseIndex = attributeMapping.getIndexMetadata().getListIndexBase();
|
||||||
|
if ( baseIndex > 0 ) {
|
||||||
index = (Integer)index - baseIndex;
|
index = (Integer)index - baseIndex;
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object incrementIndexByBase(Object index) {
|
protected Object incrementIndexByBase(Object index) {
|
||||||
if ( baseIndex != 0 ) {
|
final int baseIndex = attributeMapping.getIndexMetadata().getListIndexBase();
|
||||||
|
if ( baseIndex > 0 ) {
|
||||||
index = (Integer)index + baseIndex;
|
index = (Integer)index + baseIndex;
|
||||||
}
|
}
|
||||||
return index;
|
return index;
|
||||||
|
@ -888,12 +835,12 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isArray() {
|
public boolean isArray() {
|
||||||
return isArray;
|
return collectionSemantics.getCollectionClassification() == CollectionClassification.ARRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifierColumnName() {
|
public String getIdentifierColumnName() {
|
||||||
if ( hasIdentifier ) {
|
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
|
||||||
return identifierColumnName;
|
return identifierColumnName;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -950,7 +897,7 @@ public abstract class AbstractCollectionPersister
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hasIndex ) {
|
if ( hasIndex() ) {
|
||||||
for ( String indexAlias : indexColumnAliases ) {
|
for ( String indexAlias : indexColumnAliases ) {
|
||||||
sqlSelections.set(
|
sqlSelections.set(
|
||||||
i,
|
i,
|
||||||
|
@ -963,7 +910,7 @@ public abstract class AbstractCollectionPersister
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( hasIdentifier ) {
|
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
|
||||||
sqlSelections.set(
|
sqlSelections.set(
|
||||||
i,
|
i,
|
||||||
new SqlSelectionImpl(
|
new SqlSelectionImpl(
|
||||||
|
@ -1088,7 +1035,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasIndex() {
|
public boolean hasIndex() {
|
||||||
return hasIndex;
|
return collectionSemantics.getCollectionClassification().isIndexed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1125,7 +1072,7 @@ public abstract class AbstractCollectionPersister
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwnerEntityName() {
|
public String getOwnerEntityName() {
|
||||||
return entityName;
|
return ownerPersister.getEntityName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1143,11 +1090,6 @@ public abstract class AbstractCollectionPersister
|
||||||
return identifierGenerator;
|
return identifierGenerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Type getIdentifierType() {
|
|
||||||
return identifierType;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasOrphanDelete() {
|
public boolean hasOrphanDelete() {
|
||||||
return hasOrphanDelete;
|
return hasOrphanDelete;
|
||||||
|
@ -1410,10 +1352,10 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
initCollectionPropertyMap( "key", keyType, keyColumnAliases );
|
initCollectionPropertyMap( "key", keyType, keyColumnAliases );
|
||||||
initCollectionPropertyMap( "element", elementType, elementColumnAliases );
|
initCollectionPropertyMap( "element", elementType, elementColumnAliases );
|
||||||
if ( hasIndex ) {
|
if ( hasIndex() ) {
|
||||||
initCollectionPropertyMap( "index", indexType, indexColumnAliases );
|
initCollectionPropertyMap( "index", indexType, indexColumnAliases );
|
||||||
}
|
}
|
||||||
if ( hasIdentifier ) {
|
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
|
||||||
initCollectionPropertyMap( "id", identifierType, new String[] { identifierColumnAlias } );
|
initCollectionPropertyMap( "id", identifierType, new String[] { identifierColumnAlias } );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1445,6 +1387,7 @@ public abstract class AbstractCollectionPersister
|
||||||
getKeyType().nullSafeSet( st, key, 1, session );
|
getKeyType().nullSafeSet( st, key, 1, session );
|
||||||
ResultSet rs = jdbcCoordinator.getResultSetReturn().extract( st );
|
ResultSet rs = jdbcCoordinator.getResultSetReturn().extract( st );
|
||||||
try {
|
try {
|
||||||
|
final int baseIndex = Math.max( attributeMapping.getIndexMetadata().getListIndexBase(), 0 );
|
||||||
return rs.next() ? rs.getInt( 1 ) - baseIndex : 0;
|
return rs.next() ? rs.getInt( 1 ) - baseIndex : 0;
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -1617,7 +1560,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasPhysicalIndexColumn() {
|
public boolean hasPhysicalIndexColumn() {
|
||||||
return hasIndex && !indexContainsFormula;
|
return hasIndex() && !indexContainsFormula;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1791,6 +1734,56 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// Types (the methods are already deprecated on CollectionPersister)
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@Deprecated private final CollectionType collectionType;
|
||||||
|
@Deprecated private final Type keyType;
|
||||||
|
@Deprecated private final Type identifierType;
|
||||||
|
@Deprecated private final Type indexType;
|
||||||
|
@Deprecated protected final Type elementType;
|
||||||
|
|
||||||
|
public CollectionType getCollectionType() {
|
||||||
|
return collectionType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getKeyType() {
|
||||||
|
return keyType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getIdentifierType() {
|
||||||
|
return identifierType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getIndexType() {
|
||||||
|
return indexType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Type getElementType() {
|
||||||
|
return elementType;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// State related to this we handle differently in 6+. In other words, state
|
||||||
|
// that is no longer needed
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@Deprecated protected final String[] keyColumnAliases;
|
||||||
|
@Deprecated private final String identifierColumnAlias;
|
||||||
|
@Deprecated protected final String[] indexColumnAliases;
|
||||||
|
@Deprecated protected final String[] elementColumnAliases;
|
||||||
|
@Deprecated private final Map<String,String[]> collectionPropertyColumnAliases = new HashMap<>();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getKeyColumnAliases(String suffix) {
|
public String[] getKeyColumnAliases(String suffix) {
|
||||||
|
@ -1804,7 +1797,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getIndexColumnAliases(String suffix) {
|
public String[] getIndexColumnAliases(String suffix) {
|
||||||
if ( hasIndex ) {
|
if ( hasIndex() ) {
|
||||||
return new Alias( suffix ).toAliasStrings( indexColumnAliases );
|
return new Alias( suffix ).toAliasStrings( indexColumnAliases );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1814,7 +1807,7 @@ public abstract class AbstractCollectionPersister
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getIdentifierColumnAlias(String suffix) {
|
public String getIdentifierColumnAlias(String suffix) {
|
||||||
if ( hasIdentifier ) {
|
if ( collectionSemantics.getCollectionClassification() == CollectionClassification.ID_BAG ) {
|
||||||
return new Alias( suffix ).toAliasString( identifierColumnAlias );
|
return new Alias( suffix ).toAliasString( identifierColumnAlias );
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -640,7 +640,7 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
|
||||||
else {
|
else {
|
||||||
deleteBuilder.addKeyRestrictionsLeniently( pluralAttribute.getKeyDescriptor().getKeyPart() );
|
deleteBuilder.addKeyRestrictionsLeniently( pluralAttribute.getKeyDescriptor().getKeyPart() );
|
||||||
|
|
||||||
if ( hasIndex && !indexContainsFormula ) {
|
if ( hasIndex() && !indexContainsFormula ) {
|
||||||
assert pluralAttribute.getIndexDescriptor() != null;
|
assert pluralAttribute.getIndexDescriptor() != null;
|
||||||
deleteBuilder.addKeyRestrictionsLeniently( pluralAttribute.getIndexDescriptor() );
|
deleteBuilder.addKeyRestrictionsLeniently( pluralAttribute.getIndexDescriptor() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,15 +80,24 @@ import org.hibernate.type.Type;
|
||||||
* </li>
|
* </li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* @see QueryableCollection
|
|
||||||
* @see PersistentCollection
|
* @see PersistentCollection
|
||||||
|
* @see PluralAttributeMapping
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
*/
|
*/
|
||||||
public interface CollectionPersister extends Restrictable {
|
public interface CollectionPersister extends Restrictable {
|
||||||
|
/**
|
||||||
|
* The NavigableRole for this collection.
|
||||||
|
*/
|
||||||
NavigableRole getNavigableRole();
|
NavigableRole getNavigableRole();
|
||||||
|
|
||||||
String getRole();
|
default String getRole() {
|
||||||
|
return getNavigableRole().getFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
default PluralAttributeMapping getAttributeMapping() {
|
||||||
|
throw new UnsupportedOperationException( "CollectionPersister used for [" + getRole() + "] does not support SQL AST" );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the persister of the entity that "owns" this collection
|
* Get the persister of the entity that "owns" this collection
|
||||||
|
@ -123,22 +132,6 @@ public interface CollectionPersister extends Restrictable {
|
||||||
*/
|
*/
|
||||||
CacheEntryStructure getCacheEntryStructure();
|
CacheEntryStructure getCacheEntryStructure();
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the associated {@code Type}
|
|
||||||
*/
|
|
||||||
CollectionType getCollectionType();
|
|
||||||
/**
|
|
||||||
* Get the "key" type (the type of the foreign key)
|
|
||||||
*/
|
|
||||||
Type getKeyType();
|
|
||||||
/**
|
|
||||||
* Get the "index" type for a list or map (optional operation)
|
|
||||||
*/
|
|
||||||
Type getIndexType();
|
|
||||||
/**
|
|
||||||
* Get the "element" type
|
|
||||||
*/
|
|
||||||
Type getElementType();
|
|
||||||
/**
|
/**
|
||||||
* Return the element class of an array, or null otherwise
|
* Return the element class of an array, or null otherwise
|
||||||
*/
|
*/
|
||||||
|
@ -245,11 +238,6 @@ public interface CollectionPersister extends Restrictable {
|
||||||
return getIdentifierGenerator();
|
return getIdentifierGenerator();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the type of the surrogate key
|
|
||||||
*/
|
|
||||||
Type getIdentifierType();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this collection implement "orphan delete"?
|
* Does this collection implement "orphan delete"?
|
||||||
*/
|
*/
|
||||||
|
@ -302,10 +290,6 @@ public interface CollectionPersister extends Restrictable {
|
||||||
|
|
||||||
boolean isAffectedByEnabledFilters(SharedSessionContractImplementor session);
|
boolean isAffectedByEnabledFilters(SharedSessionContractImplementor session);
|
||||||
|
|
||||||
default PluralAttributeMapping getAttributeMapping() {
|
|
||||||
throw new UnsupportedOperationException( "CollectionPersister used for [" + getRole() + "] does not support SQL AST" );
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers) {
|
default boolean isAffectedByEnabledFilters(LoadQueryInfluencers influencers) {
|
||||||
throw new UnsupportedOperationException( "CollectionPersister used for [" + getRole() + "] does not support SQL AST" );
|
throw new UnsupportedOperationException( "CollectionPersister used for [" + getRole() + "] does not support SQL AST" );
|
||||||
}
|
}
|
||||||
|
@ -408,4 +392,54 @@ public interface CollectionPersister extends Restrictable {
|
||||||
*/
|
*/
|
||||||
@Deprecated( since = "6", forRemoval = true )
|
@Deprecated( since = "6", forRemoval = true )
|
||||||
String getIdentifierColumnAlias(String suffix);
|
String getIdentifierColumnAlias(String suffix);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the associated {@code Type}
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate is moving away from {@link Type}. Corresponding
|
||||||
|
* {@linkplain org.hibernate.metamodel.mapping mapping metamodel} calls should
|
||||||
|
* be used instead - here (generally), {@link PluralAttributeMapping}
|
||||||
|
*/
|
||||||
|
@Deprecated( forRemoval = true )
|
||||||
|
CollectionType getCollectionType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "key" type (the type of the foreign key)
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate is moving away from {@link Type}. Corresponding
|
||||||
|
* {@linkplain org.hibernate.metamodel.mapping mapping metamodel} calls should
|
||||||
|
* be used instead - here, {@link PluralAttributeMapping#getKeyDescriptor()}
|
||||||
|
*/
|
||||||
|
@Deprecated( forRemoval = true )
|
||||||
|
Type getKeyType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "index" type for a list or map (optional operation)
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate is moving away from {@link Type}. Corresponding
|
||||||
|
* {@linkplain org.hibernate.metamodel.mapping mapping metamodel} calls should
|
||||||
|
* be used instead - here, {@link PluralAttributeMapping#getIndexDescriptor()}
|
||||||
|
*/
|
||||||
|
@Deprecated( forRemoval = true )
|
||||||
|
Type getIndexType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the "element" type
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate is moving away from {@link Type}. Corresponding
|
||||||
|
* {@linkplain org.hibernate.metamodel.mapping mapping metamodel} calls should
|
||||||
|
* be used instead - here, {@link PluralAttributeMapping#getElementDescriptor()}
|
||||||
|
*/
|
||||||
|
@Deprecated( forRemoval = true )
|
||||||
|
Type getElementType();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the type of the surrogate key
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate is moving away from {@link Type}. Corresponding
|
||||||
|
* {@linkplain org.hibernate.metamodel.mapping mapping metamodel} calls should
|
||||||
|
* be used instead - here, {@link PluralAttributeMapping#getIdentifierDescriptor()}
|
||||||
|
*/
|
||||||
|
@Deprecated( forRemoval = true )
|
||||||
|
Type getIdentifierType();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import org.hibernate.metadata.CollectionMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Just used to singly extend all the deprecated collection persister roles
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public interface DeprecatedCollectionStuff extends SQLLoadableCollection, CollectionMetadata {
|
||||||
|
@Override
|
||||||
|
default String getRole() {
|
||||||
|
return SQLLoadableCollection.super.getRole();
|
||||||
|
}
|
||||||
|
}
|
|
@ -213,7 +213,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
|
|
||||||
// If one-to-many and inverse, still need to create the index. See HHH-5732.
|
// If one-to-many and inverse, still need to create the index. See HHH-5732.
|
||||||
final boolean doWrite = isInverse
|
final boolean doWrite = isInverse
|
||||||
&& hasIndex
|
&& hasIndex()
|
||||||
&& !indexContainsFormula
|
&& !indexContainsFormula
|
||||||
&& ArrayHelper.countTrue( indexColumnIsSettable ) > 0;
|
&& ArrayHelper.countTrue( indexColumnIsSettable ) > 0;
|
||||||
if ( !doWrite ) {
|
if ( !doWrite ) {
|
||||||
|
@ -328,7 +328,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
assert fkDescriptor != null;
|
assert fkDescriptor != null;
|
||||||
|
|
||||||
final int keyColumnCount = fkDescriptor.getJdbcTypeCount();
|
final int keyColumnCount = fkDescriptor.getJdbcTypeCount();
|
||||||
final int valuesCount = hasIndex
|
final int valuesCount = hasIndex()
|
||||||
? keyColumnCount + indexColumnNames.length
|
? keyColumnCount + indexColumnNames.length
|
||||||
: keyColumnCount;
|
: keyColumnCount;
|
||||||
|
|
||||||
|
@ -360,7 +360,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( hasIndex && !indexContainsFormula ) {
|
if ( hasIndex() && !indexContainsFormula ) {
|
||||||
getAttributeMapping().getIndexDescriptor().forEachSelectable( (selectionIndex, selectableMapping) -> {
|
getAttributeMapping().getIndexDescriptor().forEachSelectable( (selectionIndex, selectableMapping) -> {
|
||||||
if ( ! selectableMapping.isUpdateable() ) {
|
if ( ! selectableMapping.isUpdateable() ) {
|
||||||
return;
|
return;
|
||||||
|
@ -402,7 +402,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
final RowMutationOperations.Values writeIndexValues;
|
final RowMutationOperations.Values writeIndexValues;
|
||||||
final RowMutationOperations.Restrictions writeIndexRestrictions;
|
final RowMutationOperations.Restrictions writeIndexRestrictions;
|
||||||
final boolean needsWriteIndex = isInverse
|
final boolean needsWriteIndex = isInverse
|
||||||
&& hasIndex
|
&& hasIndex()
|
||||||
&& !indexContainsFormula
|
&& !indexContainsFormula
|
||||||
&& !ArrayHelper.isAllFalse( indexColumnIsSettable );
|
&& !ArrayHelper.isAllFalse( indexColumnIsSettable );
|
||||||
if ( needsWriteIndex ) {
|
if ( needsWriteIndex ) {
|
||||||
|
@ -592,7 +592,7 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set the value for each index column to null
|
// set the value for each index column to null
|
||||||
if ( hasIndex && !indexContainsFormula ) {
|
if ( hasIndex() && !indexContainsFormula ) {
|
||||||
final CollectionPart indexDescriptor = getAttributeMapping().getIndexDescriptor();
|
final CollectionPart indexDescriptor = getAttributeMapping().getIndexDescriptor();
|
||||||
assert indexDescriptor != null;
|
assert indexDescriptor != null;
|
||||||
|
|
||||||
|
|
|
@ -309,20 +309,15 @@ import static org.hibernate.sql.ast.spi.SqlExpressionResolver.createColumnRefere
|
||||||
*/
|
*/
|
||||||
@Internal
|
@Internal
|
||||||
public abstract class AbstractEntityPersister
|
public abstract class AbstractEntityPersister
|
||||||
implements OuterJoinLoadable, ClassMetadata, UniqueKeyLoadable,
|
implements InFlightEntityMappingType, EntityMutationTarget, LazyPropertyInitializer, PostInsertIdentityPersister, DeprecatedEntityStuff {
|
||||||
SQLLoadable, LazyPropertyInitializer, PostInsertIdentityPersister, Lockable,
|
|
||||||
org.hibernate.persister.entity.Queryable, InFlightEntityMappingType, EntityMutationTarget {
|
|
||||||
|
|
||||||
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
|
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( AbstractEntityPersister.class );
|
||||||
|
|
||||||
public static final String ENTITY_CLASS = "class";
|
public static final String ENTITY_CLASS = "class";
|
||||||
public static final String VERSION_COLUMN_ALIAS = "version_";
|
public static final String VERSION_COLUMN_ALIAS = "version_";
|
||||||
|
|
||||||
private final SessionFactoryImplementor factory;
|
|
||||||
|
|
||||||
private final NavigableRole navigableRole;
|
private final NavigableRole navigableRole;
|
||||||
|
private final SessionFactoryImplementor factory;
|
||||||
private final EntityMetamodel entityMetamodel;
|
|
||||||
private final EntityEntryFactory entityEntryFactory;
|
private final EntityEntryFactory entityEntryFactory;
|
||||||
|
|
||||||
private final String sqlAliasStem;
|
private final String sqlAliasStem;
|
||||||
|
@ -332,18 +327,6 @@ public abstract class AbstractEntityPersister
|
||||||
private NaturalIdLoader<?> naturalIdLoader;
|
private NaturalIdLoader<?> naturalIdLoader;
|
||||||
private MultiNaturalIdLoader<?> multiNaturalIdLoader;
|
private MultiNaturalIdLoader<?> multiNaturalIdLoader;
|
||||||
|
|
||||||
private SqmMultiTableMutationStrategy sqmMultiTableMutationStrategy;
|
|
||||||
private SqmMultiTableInsertStrategy sqmMultiTableInsertStrategy;
|
|
||||||
|
|
||||||
private final EntityDataAccess cacheAccessStrategy;
|
|
||||||
private final NaturalIdDataAccess naturalIdRegionAccessStrategy;
|
|
||||||
private final CacheEntryHelper cacheEntryHelper;
|
|
||||||
private final boolean canReadFromCache;
|
|
||||||
private final boolean canWriteToCache;
|
|
||||||
private final boolean invalidateCache;
|
|
||||||
private final boolean isLazyPropertiesCacheable;
|
|
||||||
private final boolean useReferenceCacheEntries;
|
|
||||||
|
|
||||||
private final String[] rootTableKeyColumnNames;
|
private final String[] rootTableKeyColumnNames;
|
||||||
private final String[] rootTableKeyColumnReaders;
|
private final String[] rootTableKeyColumnReaders;
|
||||||
private final String[] rootTableKeyColumnReaderTemplates;
|
private final String[] rootTableKeyColumnReaderTemplates;
|
||||||
|
@ -392,47 +375,39 @@ public abstract class AbstractEntityPersister
|
||||||
private final boolean[] propertyDefinedOnSubclass;
|
private final boolean[] propertyDefinedOnSubclass;
|
||||||
private final CascadeStyle[] subclassPropertyCascadeStyleClosure;
|
private final CascadeStyle[] subclassPropertyCascadeStyleClosure;
|
||||||
|
|
||||||
//information about all columns/formulas in class hierarchy
|
private Map<String, SingleIdArrayLoadPlan> lazyLoadPlanByFetchGroup;
|
||||||
private final String[] subclassColumnAliasClosure;
|
|
||||||
private final String[] subclassFormulaAliasClosure;
|
|
||||||
|
|
||||||
// dynamic filters attached to the class-level
|
|
||||||
private final FilterHelper filterHelper;
|
|
||||||
private volatile Set<String> affectingFetchProfileNames;
|
|
||||||
|
|
||||||
private final LockModeEnumMap<LockingStrategy> lockers = new LockModeEnumMap<>();
|
private final LockModeEnumMap<LockingStrategy> lockers = new LockModeEnumMap<>();
|
||||||
|
private String sqlVersionSelectString;
|
||||||
|
|
||||||
private EntityTableMapping[] tableMappings;
|
private EntityTableMapping[] tableMappings;
|
||||||
private InsertCoordinator insertCoordinator;
|
private InsertCoordinator insertCoordinator;
|
||||||
private UpdateCoordinator updateCoordinator;
|
private UpdateCoordinator updateCoordinator;
|
||||||
private DeleteCoordinator deleteCoordinator;
|
private DeleteCoordinator deleteCoordinator;
|
||||||
|
|
||||||
protected Expectation[] insertExpectations;
|
private SqmMultiTableMutationStrategy sqmMultiTableMutationStrategy;
|
||||||
protected Expectation[] updateExpectations;
|
private SqmMultiTableInsertStrategy sqmMultiTableInsertStrategy;
|
||||||
protected Expectation[] deleteExpectations;
|
|
||||||
|
|
||||||
// SQL strings
|
private final EntityDataAccess cacheAccessStrategy;
|
||||||
private String sqlVersionSelectString;
|
private final NaturalIdDataAccess naturalIdRegionAccessStrategy;
|
||||||
private Map<String, SingleIdArrayLoadPlan> lazyLoadPlanByFetchGroup;
|
private final CacheEntryHelper cacheEntryHelper;
|
||||||
|
private final boolean canReadFromCache;
|
||||||
|
private final boolean canWriteToCache;
|
||||||
|
private final boolean invalidateCache;
|
||||||
|
private final boolean isLazyPropertiesCacheable;
|
||||||
|
private final boolean useReferenceCacheEntries;
|
||||||
|
|
||||||
|
// dynamic filters attached to the class-level
|
||||||
|
private final FilterHelper filterHelper;
|
||||||
|
private volatile Set<String> affectingFetchProfileNames;
|
||||||
|
|
||||||
private GeneratedValuesProcessor insertGeneratedValuesProcessor;
|
private GeneratedValuesProcessor insertGeneratedValuesProcessor;
|
||||||
private GeneratedValuesProcessor updateGeneratedValuesProcessor;
|
private GeneratedValuesProcessor updateGeneratedValuesProcessor;
|
||||||
|
|
||||||
//Custom SQL (would be better if these were private)
|
|
||||||
protected boolean[] insertCallable;
|
|
||||||
protected boolean[] updateCallable;
|
|
||||||
protected boolean[] deleteCallable;
|
|
||||||
protected String[] customSQLInsert;
|
|
||||||
protected String[] customSQLUpdate;
|
|
||||||
protected String[] customSQLDelete;
|
|
||||||
|
|
||||||
private InsertGeneratedIdentifierDelegate identityDelegate;
|
private InsertGeneratedIdentifierDelegate identityDelegate;
|
||||||
private String identitySelectString;
|
private String identitySelectString;
|
||||||
|
|
||||||
private boolean[] tableHasColumns;
|
private boolean[] tableHasColumns;
|
||||||
|
|
||||||
private final Map<String,String[]> subclassPropertyAliases = new HashMap<>();
|
|
||||||
private final Map<String,String[]> subclassPropertyColumnNames = new HashMap<>();
|
private final Map<String,String[]> subclassPropertyColumnNames = new HashMap<>();
|
||||||
|
|
||||||
private final JavaType<?> javaType;
|
private final JavaType<?> javaType;
|
||||||
|
@ -455,7 +430,6 @@ public abstract class AbstractEntityPersister
|
||||||
|
|
||||||
protected ReflectionOptimizer.AccessOptimizer accessOptimizer;
|
protected ReflectionOptimizer.AccessOptimizer accessOptimizer;
|
||||||
|
|
||||||
// private final String[] fullDiscriminatorSQLValues;
|
|
||||||
private final Object[] fullDiscriminatorValues;
|
private final Object[] fullDiscriminatorValues;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -938,10 +912,6 @@ public abstract class AbstractEntityPersister
|
||||||
: Template.TEMPLATE + "." + DISCRIMINATOR_ALIAS;
|
: Template.TEMPLATE + "." + DISCRIMINATOR_ALIAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDiscriminatorAlias() {
|
|
||||||
return DISCRIMINATOR_ALIAS;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDiscriminatorFormulaTemplate() {
|
public String getDiscriminatorFormulaTemplate() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -2468,136 +2438,12 @@ public abstract class AbstractEntityPersister
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// returns the aliases of the selectable columns
|
|
||||||
protected String[] getSubclassColumnAliasClosure() {
|
|
||||||
return subclassColumnAliasClosure;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected String[] getSubclassFormulaAliasClosure() {
|
|
||||||
return subclassFormulaAliasClosure;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getSubclassPropertyColumnAliases(String propertyName, String suffix) {
|
|
||||||
final String[] rawAliases = subclassPropertyAliases.get( propertyName );
|
|
||||||
if ( rawAliases == null ) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
final String[] result = new String[rawAliases.length];
|
|
||||||
for ( int i = 0; i < rawAliases.length; i++ ) {
|
|
||||||
result[i] = new Alias( suffix ).toUnquotedAliasString( rawAliases[i] );
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String[] getSubclassPropertyColumnNames(String propertyName) {
|
public String[] getSubclassPropertyColumnNames(String propertyName) {
|
||||||
//TODO: should we allow suffixes on these ?
|
//TODO: should we allow suffixes on these ?
|
||||||
return subclassPropertyColumnNames.get( propertyName );
|
return subclassPropertyColumnNames.get( propertyName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//This is really ugly, but necessary:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called by subclasses, at the end of their constructors
|
|
||||||
*/
|
|
||||||
protected void initSubclassPropertyAliasesMap(PersistentClass model) throws MappingException {
|
|
||||||
|
|
||||||
// ALIASES
|
|
||||||
internalInitSubclassPropertyAliasesMap( null, model.getSubclassPropertyClosure() );
|
|
||||||
|
|
||||||
// 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
|
|
||||||
if ( getIdentifierType().isComponentType() ) {
|
|
||||||
// Fetch embedded identifiers property names from the "virtual" identifier component
|
|
||||||
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() ) {
|
|
||||||
subclassPropertyAliases.put(
|
|
||||||
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() ) {
|
|
||||||
subclassPropertyAliases.put(
|
|
||||||
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()} );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private void internalInitSubclassPropertyAliasesMap(String path, List<Property> properties) {
|
|
||||||
for (Property property : properties) {
|
|
||||||
final String name = path == null ? property.getName() : path + "." + property.getName();
|
|
||||||
if ( property.isComposite() ) {
|
|
||||||
Component component = (Component) property.getValue();
|
|
||||||
internalInitSubclassPropertyAliasesMap( name, component.getProperties() );
|
|
||||||
}
|
|
||||||
|
|
||||||
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++;
|
|
||||||
}
|
|
||||||
|
|
||||||
subclassPropertyAliases.put( name, aliases );
|
|
||||||
subclassPropertyColumnNames.put( name, cols );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Called by Hibernate Reactive
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
protected String[][] getLazyPropertyColumnAliases() {
|
|
||||||
return lazyPropertyColumnAliases;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object loadByUniqueKey(
|
public Object loadByUniqueKey(
|
||||||
String propertyName,
|
String propertyName,
|
||||||
|
@ -5954,8 +5800,13 @@ public abstract class AbstractEntityPersister
|
||||||
return hasPartitionedSelectionMapping;
|
return hasPartitionedSelectionMapping;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
// Deprecations
|
// Deprecations
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated With no replacement
|
* @deprecated With no replacement
|
||||||
|
@ -6252,4 +6103,193 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// State built and stored here during instantiation, and only used in other
|
||||||
|
// phases of initialization
|
||||||
|
// - postConstruct
|
||||||
|
// - postInstantiate
|
||||||
|
// - prepareMappingModel
|
||||||
|
// - ...
|
||||||
|
//
|
||||||
|
// This is effectively bootstrap state that is kept around during runtime.
|
||||||
|
//
|
||||||
|
// Would be better to encapsulate and store this state relative to the
|
||||||
|
// `PersisterCreationContext` so it can get released after bootstrap
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@Deprecated protected Expectation[] insertExpectations;
|
||||||
|
@Deprecated protected Expectation[] updateExpectations;
|
||||||
|
@Deprecated protected Expectation[] deleteExpectations;
|
||||||
|
|
||||||
|
@Deprecated protected boolean[] insertCallable;
|
||||||
|
@Deprecated protected boolean[] updateCallable;
|
||||||
|
@Deprecated protected boolean[] deleteCallable;
|
||||||
|
|
||||||
|
@Deprecated protected String[] customSQLInsert;
|
||||||
|
@Deprecated protected String[] customSQLUpdate;
|
||||||
|
@Deprecated protected String[] customSQLDelete;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// State related to this we handle differently in 6+. In other words, state
|
||||||
|
// that is no longer needed
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@Deprecated private final EntityMetamodel entityMetamodel;
|
||||||
|
|
||||||
|
@Deprecated private final String[] subclassColumnAliasClosure;
|
||||||
|
@Deprecated private final String[] subclassFormulaAliasClosure;
|
||||||
|
@Deprecated private final Map<String,String[]> subclassPropertyAliases = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated protected String[] getSubclassColumnAliasClosure() {
|
||||||
|
return subclassColumnAliasClosure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated protected String[] getSubclassFormulaAliasClosure() {
|
||||||
|
return subclassFormulaAliasClosure;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated @Override
|
||||||
|
public String[] getSubclassPropertyColumnAliases(String propertyName, String suffix) {
|
||||||
|
final String[] rawAliases = subclassPropertyAliases.get( propertyName );
|
||||||
|
if ( rawAliases == null ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
final String[] result = new String[rawAliases.length];
|
||||||
|
for ( int i = 0; i < rawAliases.length; i++ ) {
|
||||||
|
result[i] = new Alias( suffix ).toUnquotedAliasString( rawAliases[i] );
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Must be called by subclasses, at the end of their constructors
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated protected void initSubclassPropertyAliasesMap(PersistentClass model) throws MappingException {
|
||||||
|
|
||||||
|
// ALIASES
|
||||||
|
internalInitSubclassPropertyAliasesMap( null, model.getSubclassPropertyClosure() );
|
||||||
|
|
||||||
|
// 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
|
||||||
|
if ( getIdentifierType().isComponentType() ) {
|
||||||
|
// Fetch embedded identifiers property names from the "virtual" identifier component
|
||||||
|
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() ) {
|
||||||
|
subclassPropertyAliases.put(
|
||||||
|
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() ) {
|
||||||
|
subclassPropertyAliases.put(
|
||||||
|
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()} );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void internalInitSubclassPropertyAliasesMap(String path, List<Property> properties) {
|
||||||
|
for (Property property : properties) {
|
||||||
|
final String name = path == null ? property.getName() : path + "." + property.getName();
|
||||||
|
if ( property.isComposite() ) {
|
||||||
|
Component component = (Component) property.getValue();
|
||||||
|
internalInitSubclassPropertyAliasesMap( name, component.getProperties() );
|
||||||
|
}
|
||||||
|
|
||||||
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
subclassPropertyAliases.put( name, aliases );
|
||||||
|
subclassPropertyColumnNames.put( name, cols );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called by Hibernate Reactive
|
||||||
|
*
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated @SuppressWarnings("unused")
|
||||||
|
protected String[][] getLazyPropertyColumnAliases() {
|
||||||
|
return lazyPropertyColumnAliases;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Hibernate no longer uses aliases to read from result sets
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public String getDiscriminatorAlias() {
|
||||||
|
return DISCRIMINATOR_ALIAS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
/*
|
||||||
|
* 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.metadata.ClassMetadata;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Just used to singly extend all the deprecated entity persister roles
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public interface DeprecatedEntityStuff
|
||||||
|
extends OuterJoinLoadable, ClassMetadata, UniqueKeyLoadable, SQLLoadable, Lockable, org.hibernate.persister.entity.Queryable {
|
||||||
|
}
|
|
@ -590,6 +590,14 @@ public interface EntityPersister extends EntityMappingType, RootTableGroupProduc
|
||||||
*/
|
*/
|
||||||
List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions);
|
List<?> multiLoad(Object[] ids, EventSource session, MultiIdLoadOptions loadOptions);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
default Object loadByUniqueKey(String propertyName, Object uniqueKey, SharedSessionContractImplementor session) {
|
||||||
|
throw new UnsupportedOperationException(
|
||||||
|
"EntityPersister implementation '" + getClass().getName()
|
||||||
|
+ "' does not support 'UniqueKeyLoadable'"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do a version check (optional operation)
|
* Do a version check (optional operation)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -113,7 +113,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
private final String discriminatorColumnReaders;
|
private final String discriminatorColumnReaders;
|
||||||
private final String discriminatorColumnReaderTemplate;
|
private final String discriminatorColumnReaderTemplate;
|
||||||
private final String discriminatorFormulaTemplate;
|
private final String discriminatorFormulaTemplate;
|
||||||
private final String discriminatorAlias;
|
|
||||||
private final BasicType<?> discriminatorType;
|
private final BasicType<?> discriminatorType;
|
||||||
private final Object discriminatorValue;
|
private final Object discriminatorValue;
|
||||||
private final String discriminatorSQLValue;
|
private final String discriminatorSQLValue;
|
||||||
|
@ -122,11 +121,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
private final String[] constraintOrderedTableNames;
|
private final String[] constraintOrderedTableNames;
|
||||||
private final String[][] constraintOrderedKeyColumnNames;
|
private final String[][] constraintOrderedKeyColumnNames;
|
||||||
|
|
||||||
//private final Map propertyTableNumbersByName = new HashMap();
|
|
||||||
// private final Map<String, Integer> propertyTableNumbersByNameAndSubclass;
|
|
||||||
|
|
||||||
//INITIALIZATION:
|
|
||||||
|
|
||||||
@Deprecated(since = "6.0")
|
@Deprecated(since = "6.0")
|
||||||
public SingleTableEntityPersister(
|
public SingleTableEntityPersister(
|
||||||
final PersistentClass persistentClass,
|
final PersistentClass persistentClass,
|
||||||
|
@ -321,7 +315,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
discriminatorInsertable = isDiscriminatorInsertable( persistentClass );
|
discriminatorInsertable = isDiscriminatorInsertable( persistentClass );
|
||||||
if ( discriminator.hasFormula() ) {
|
if ( discriminator.hasFormula() ) {
|
||||||
final Formula formula = (Formula) selectable;
|
final Formula formula = (Formula) selectable;
|
||||||
// discriminatorFormula = formula.getFormula();
|
|
||||||
discriminatorFormulaTemplate = formula.getTemplate( dialect, typeConfiguration, functionRegistry );
|
discriminatorFormulaTemplate = formula.getTemplate( dialect, typeConfiguration, functionRegistry );
|
||||||
discriminatorColumnName = null;
|
discriminatorColumnName = null;
|
||||||
discriminatorColumnReaders = null;
|
discriminatorColumnReaders = null;
|
||||||
|
@ -334,7 +327,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
discriminatorColumnReaders = column.getReadExpr( dialect );
|
discriminatorColumnReaders = column.getReadExpr( dialect );
|
||||||
discriminatorColumnReaderTemplate = column.getTemplate( dialect, typeConfiguration, functionRegistry );
|
discriminatorColumnReaderTemplate = column.getTemplate( dialect, typeConfiguration, functionRegistry );
|
||||||
discriminatorAlias = column.getAlias( dialect, persistentClass.getRootTable() );
|
discriminatorAlias = column.getAlias( dialect, persistentClass.getRootTable() );
|
||||||
// discriminatorFormula = null;
|
|
||||||
discriminatorFormulaTemplate = null;
|
discriminatorFormulaTemplate = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -452,11 +444,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
return discriminatorColumnReaderTemplate;
|
return discriminatorColumnReaderTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDiscriminatorAlias() {
|
|
||||||
return discriminatorAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDiscriminatorFormulaTemplate() {
|
public String getDiscriminatorFormulaTemplate() {
|
||||||
return discriminatorFormulaTemplate;
|
return discriminatorFormulaTemplate;
|
||||||
|
@ -748,4 +735,17 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// Deprecations
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
@Deprecated private final String discriminatorAlias;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDiscriminatorAlias() {
|
||||||
|
return discriminatorAlias;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,10 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
* An {@link EntityPersister} that can be loaded by a non-primary unique key.
|
* An {@link EntityPersister} that can be loaded by a non-primary unique key.
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
*
|
||||||
|
* @deprecated Use {@link org.hibernate.metamodel.mapping.EntityMappingType#loadByUniqueKey} instead
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public interface UniqueKeyLoadable extends Loadable {
|
public interface UniqueKeyLoadable extends Loadable {
|
||||||
/**
|
/**
|
||||||
* Load an instance of the persistent class, by a unique key other
|
* Load an instance of the persistent class, by a unique key other
|
||||||
|
|
|
@ -16,5 +16,12 @@
|
||||||
* defines a mechanism for persisting instances of a given
|
* defines a mechanism for persisting instances of a given
|
||||||
* collection role.
|
* collection role.
|
||||||
* </ul>
|
* </ul>
|
||||||
|
*
|
||||||
|
* @apiNote This package is considered an SPI, meaning it is intended for use
|
||||||
|
* by internal code and by integrations. It is not supported for application use.
|
||||||
|
* Be aware that its backwards compatibility guarantee is tied defined by SPI which
|
||||||
|
* is less strict than API, which <b>is</b> intended for application use (things
|
||||||
|
* like {@link org.hibernate.SessionFactory}, {@link org.hibernate.Session},
|
||||||
|
* {@link org.hibernate.Transaction}, etc.).
|
||||||
*/
|
*/
|
||||||
package org.hibernate.persister;
|
package org.hibernate.persister;
|
||||||
|
|
|
@ -674,6 +674,11 @@ public class AnonymousTupleEntityValuedModelPart
|
||||||
delegate.getEntityMappingType().visitConstraintOrderedTables( consumer );
|
delegate.getEntityMappingType().visitConstraintOrderedTables( consumer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object loadByUniqueKey(String propertyName, Object uniqueKey, SharedSessionContractImplementor session) {
|
||||||
|
return delegate.getEntityMappingType().loadByUniqueKey( propertyName, uniqueKey, session );
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NaturalIdLoader<?> getNaturalIdLoader() {
|
public NaturalIdLoader<?> getNaturalIdLoader() {
|
||||||
return delegate.getEntityMappingType().getNaturalIdLoader();
|
return delegate.getEntityMappingType().getNaturalIdLoader();
|
||||||
|
|
|
@ -17,7 +17,6 @@ import org.hibernate.internal.log.LoggingHelper;
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
import org.hibernate.metamodel.mapping.ModelPart;
|
||||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.spi.NavigablePath;
|
import org.hibernate.spi.NavigablePath;
|
||||||
|
@ -147,7 +146,7 @@ public class EntityDelayedFetchInitializer extends AbstractFetchParentAccess imp
|
||||||
&& isEnhancedForLazyLoading( parentEntityInitializer ) ) {
|
&& isEnhancedForLazyLoading( parentEntityInitializer ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entityInstance = ( (UniqueKeyLoadable) concreteDescriptor ).loadByUniqueKey(
|
entityInstance = concreteDescriptor.loadByUniqueKey(
|
||||||
uniqueKeyPropertyName,
|
uniqueKeyPropertyName,
|
||||||
identifier,
|
identifier,
|
||||||
session
|
session
|
||||||
|
|
|
@ -11,7 +11,6 @@ import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
|
||||||
import org.hibernate.spi.NavigablePath;
|
import org.hibernate.spi.NavigablePath;
|
||||||
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
import org.hibernate.sql.results.graph.DomainResultAssembler;
|
||||||
import org.hibernate.sql.results.graph.FetchParentAccess;
|
import org.hibernate.sql.results.graph.FetchParentAccess;
|
||||||
|
@ -83,7 +82,7 @@ public class EntitySelectFetchByUniqueKeyInitializer extends EntitySelectFetchIn
|
||||||
final JdbcValuesSourceProcessingState jdbcValuesSourceProcessingState = rowProcessingState.getJdbcValuesSourceProcessingState();
|
final JdbcValuesSourceProcessingState jdbcValuesSourceProcessingState = rowProcessingState.getJdbcValuesSourceProcessingState();
|
||||||
jdbcValuesSourceProcessingState.registerInitializer( euk, this );
|
jdbcValuesSourceProcessingState.registerInitializer( euk, this );
|
||||||
|
|
||||||
entityInstance = ( (UniqueKeyLoadable) concreteDescriptor ).loadByUniqueKey(
|
entityInstance = concreteDescriptor.loadByUniqueKey(
|
||||||
uniqueKeyPropertyName,
|
uniqueKeyPropertyName,
|
||||||
entityIdentifier,
|
entityIdentifier,
|
||||||
session
|
session
|
||||||
|
|
|
@ -13,11 +13,9 @@ import org.hibernate.engine.spi.EntityKey;
|
||||||
import org.hibernate.engine.spi.EntityUniqueKey;
|
import org.hibernate.engine.spi.EntityUniqueKey;
|
||||||
import org.hibernate.engine.spi.PersistenceContext;
|
import org.hibernate.engine.spi.PersistenceContext;
|
||||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.metamodel.mapping.AttributeMapping;
|
|
||||||
import org.hibernate.metamodel.mapping.ModelPart;
|
import org.hibernate.metamodel.mapping.ModelPart;
|
||||||
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.entity.UniqueKeyLoadable;
|
|
||||||
import org.hibernate.proxy.HibernateProxy;
|
import org.hibernate.proxy.HibernateProxy;
|
||||||
import org.hibernate.proxy.LazyInitializer;
|
import org.hibernate.proxy.LazyInitializer;
|
||||||
import org.hibernate.spi.NavigablePath;
|
import org.hibernate.spi.NavigablePath;
|
||||||
|
@ -208,7 +206,7 @@ public class CircularBiDirectionalFetchImpl implements BiDirectionalFetch {
|
||||||
);
|
);
|
||||||
Object entityInstance = persistenceContext.getEntity( euk );
|
Object entityInstance = persistenceContext.getEntity( euk );
|
||||||
if ( entityInstance == null ) {
|
if ( entityInstance == null ) {
|
||||||
entityInstance = ( (UniqueKeyLoadable) entityPersister ).loadByUniqueKey(
|
entityInstance = entityPersister.loadByUniqueKey(
|
||||||
uniqueKeyPropertyName,
|
uniqueKeyPropertyName,
|
||||||
key,
|
key,
|
||||||
session
|
session
|
||||||
|
|
Loading…
Reference in New Issue