get rid of warnings about use of deprecated PersisterCreationContext
This commit is contained in:
parent
1c73be8ba4
commit
ef391bf644
|
@ -10,8 +10,8 @@ import org.hibernate.MappingException;
|
||||||
import org.hibernate.cache.CacheException;
|
import org.hibernate.cache.CacheException;
|
||||||
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
import org.hibernate.cache.spi.access.CollectionDataAccess;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.collection.OneToManyPersister;
|
import org.hibernate.persister.collection.OneToManyPersister;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Shawn Clowater
|
* @author Shawn Clowater
|
||||||
|
@ -24,7 +24,7 @@ public class CollectionPersister
|
||||||
public CollectionPersister(
|
public CollectionPersister(
|
||||||
Collection collectionBinding,
|
Collection collectionBinding,
|
||||||
CollectionDataAccess cacheAccessStrategy,
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
PersisterCreationContext creationContext)
|
RuntimeModelCreationContext creationContext)
|
||||||
throws MappingException, CacheException {
|
throws MappingException, CacheException {
|
||||||
super(collectionBinding, cacheAccessStrategy, creationContext);
|
super(collectionBinding, cacheAccessStrategy, creationContext);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,9 +16,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
import static java.util.Collections.unmodifiableSet;
|
import static java.util.Collections.unmodifiableSet;
|
||||||
|
@ -38,7 +38,7 @@ public class LazyAttributesMetadata implements Serializable {
|
||||||
PersistentClass mappedEntity,
|
PersistentClass mappedEntity,
|
||||||
boolean isEnhanced,
|
boolean isEnhanced,
|
||||||
boolean collectionsInDefaultFetchGroupEnabled,
|
boolean collectionsInDefaultFetchGroupEnabled,
|
||||||
PersisterCreationContext creationContext) {
|
Metadata metadata) {
|
||||||
final Map<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap = new LinkedHashMap<>();
|
final Map<String, LazyAttributeDescriptor> lazyAttributeDescriptorMap = new LinkedHashMap<>();
|
||||||
final Map<String, Set<String>> fetchGroupToAttributesMap = new HashMap<>();
|
final Map<String, Set<String>> fetchGroupToAttributesMap = new HashMap<>();
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public class LazyAttributesMetadata implements Serializable {
|
||||||
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
|
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
|
||||||
property,
|
property,
|
||||||
isEnhanced,
|
isEnhanced,
|
||||||
(entityName) -> {
|
entityName -> {
|
||||||
final PersistentClass entityBinding = creationContext.getMetadata().getEntityBinding( entityName );
|
final PersistentClass entityBinding = metadata.getEntityBinding( entityName );
|
||||||
assert entityBinding != null;
|
assert entityBinding != null;
|
||||||
return entityBinding.hasSubclasses();
|
return entityBinding.hasSubclasses();
|
||||||
},
|
},
|
||||||
|
|
|
@ -136,6 +136,7 @@ import org.jboss.logging.Logger;
|
||||||
* Base implementation of the {@code QueryableCollection} interface.
|
* Base implementation of the {@code QueryableCollection} interface.
|
||||||
*
|
*
|
||||||
* @author Gavin King
|
* @author Gavin King
|
||||||
|
*
|
||||||
* @see BasicCollectionPersister
|
* @see BasicCollectionPersister
|
||||||
* @see OneToManyPersister
|
* @see OneToManyPersister
|
||||||
*/
|
*/
|
||||||
|
@ -277,13 +278,18 @@ public abstract class AbstractCollectionPersister
|
||||||
private final JdbcMapping convertedElementType;
|
private final JdbcMapping convertedElementType;
|
||||||
private final JdbcMapping convertedIndexType;
|
private final JdbcMapping convertedIndexType;
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public AbstractCollectionPersister(
|
public AbstractCollectionPersister(
|
||||||
Collection collectionBootDescriptor,
|
Collection collectionBootDescriptor,
|
||||||
CollectionDataAccess cacheAccessStrategy,
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
PersisterCreationContext persisterCreationContext) throws MappingException, CacheException {
|
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||||
assert persisterCreationContext instanceof RuntimeModelCreationContext;
|
this( collectionBootDescriptor, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
final RuntimeModelCreationContext creationContext = (RuntimeModelCreationContext) persisterCreationContext;
|
public AbstractCollectionPersister(
|
||||||
|
Collection collectionBootDescriptor,
|
||||||
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
|
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
||||||
|
|
||||||
final Value elementBootDescriptor = collectionBootDescriptor.getElement();
|
final Value elementBootDescriptor = collectionBootDescriptor.getElement();
|
||||||
final Value indexBootDescriptor = collectionBootDescriptor instanceof IndexedCollection
|
final Value indexBootDescriptor = collectionBootDescriptor instanceof IndexedCollection
|
||||||
|
@ -514,7 +520,7 @@ public abstract class AbstractCollectionPersister
|
||||||
identifierColumnName = col.getQuotedName( dialect );
|
identifierColumnName = col.getQuotedName( dialect );
|
||||||
identifierColumnAlias = col.getAlias( dialect );
|
identifierColumnAlias = col.getAlias( dialect );
|
||||||
identifierGenerator = idColl.getIdentifier().createIdentifierGenerator(
|
identifierGenerator = idColl.getIdentifier().createIdentifierGenerator(
|
||||||
persisterCreationContext.getBootstrapContext().getIdentifierGeneratorFactory(),
|
creationContext.getBootstrapContext().getIdentifierGeneratorFactory(),
|
||||||
factory.getJdbcServices().getDialect(),
|
factory.getJdbcServices().getDialect(),
|
||||||
null
|
null
|
||||||
);
|
);
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.jdbc.Expectation;
|
import org.hibernate.jdbc.Expectation;
|
||||||
import org.hibernate.jdbc.Expectations;
|
import org.hibernate.jdbc.Expectations;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
import org.hibernate.sql.Delete;
|
import org.hibernate.sql.Delete;
|
||||||
|
@ -47,10 +48,18 @@ public class BasicCollectionPersister extends AbstractCollectionPersister {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public BasicCollectionPersister(
|
public BasicCollectionPersister(
|
||||||
Collection collectionBinding,
|
Collection collectionBinding,
|
||||||
CollectionDataAccess cacheAccessStrategy,
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||||
|
this( collectionBinding, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public BasicCollectionPersister(
|
||||||
|
Collection collectionBinding,
|
||||||
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
|
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
||||||
super( collectionBinding, cacheAccessStrategy, creationContext );
|
super( collectionBinding, cacheAccessStrategy, creationContext );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ import org.hibernate.internal.util.collections.ArrayHelper;
|
||||||
import org.hibernate.jdbc.Expectation;
|
import org.hibernate.jdbc.Expectation;
|
||||||
import org.hibernate.jdbc.Expectations;
|
import org.hibernate.jdbc.Expectations;
|
||||||
import org.hibernate.mapping.Collection;
|
import org.hibernate.mapping.Collection;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.Joinable;
|
import org.hibernate.persister.entity.Joinable;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.pretty.MessageHelper;
|
import org.hibernate.pretty.MessageHelper;
|
||||||
|
@ -60,10 +61,18 @@ public class OneToManyPersister extends AbstractCollectionPersister {
|
||||||
return cascadeDeleteEnabled;
|
return cascadeDeleteEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public OneToManyPersister(
|
public OneToManyPersister(
|
||||||
Collection collectionBinding,
|
Collection collectionBinding,
|
||||||
CollectionDataAccess cacheAccessStrategy,
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
PersisterCreationContext creationContext) throws MappingException, CacheException {
|
||||||
|
this( collectionBinding, cacheAccessStrategy, (RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public OneToManyPersister(
|
||||||
|
Collection collectionBinding,
|
||||||
|
CollectionDataAccess cacheAccessStrategy,
|
||||||
|
RuntimeModelCreationContext creationContext) throws MappingException, CacheException {
|
||||||
super( collectionBinding, cacheAccessStrategy, creationContext );
|
super( collectionBinding, cacheAccessStrategy, creationContext );
|
||||||
cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled()
|
cascadeDeleteEnabled = collectionBinding.getKey().isCascadeDeleteEnabled()
|
||||||
&& creationContext.getSessionFactory().getJdbcServices().getDialect().supportsCascadeDelete();
|
&& creationContext.getSessionFactory().getJdbcServices().getDialect().supportsCascadeDelete();
|
||||||
|
|
|
@ -673,13 +673,21 @@ public abstract class AbstractEntityPersister
|
||||||
return tableNames;
|
return tableNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public AbstractEntityPersister(
|
public AbstractEntityPersister(
|
||||||
final PersistentClass bootDescriptor,
|
final PersistentClass bootDescriptor,
|
||||||
final EntityDataAccess cacheAccessStrategy,
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
final PersisterCreationContext pcc) throws HibernateException {
|
final PersisterCreationContext creationContext) throws HibernateException {
|
||||||
|
this( bootDescriptor, cacheAccessStrategy, naturalIdRegionAccessStrategy,
|
||||||
|
(RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
final RuntimeModelCreationContext creationContext = (RuntimeModelCreationContext) pcc;
|
public AbstractEntityPersister(
|
||||||
|
final PersistentClass bootDescriptor,
|
||||||
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
|
final RuntimeModelCreationContext creationContext) throws HibernateException {
|
||||||
|
|
||||||
this.factory = creationContext.getSessionFactory();
|
this.factory = creationContext.getSessionFactory();
|
||||||
this.sqlAliasStem = SqlAliasStemHelper.INSTANCE.generateStemFromEntityName( bootDescriptor.getEntityName() );
|
this.sqlAliasStem = SqlAliasStemHelper.INSTANCE.generateStemFromEntityName( bootDescriptor.getEntityName() );
|
||||||
|
@ -1081,7 +1089,7 @@ public abstract class AbstractEntityPersister
|
||||||
*/
|
*/
|
||||||
private boolean shouldInvalidateCache(
|
private boolean shouldInvalidateCache(
|
||||||
PersistentClass persistentClass,
|
PersistentClass persistentClass,
|
||||||
PersisterCreationContext creationContext) {
|
RuntimeModelCreationContext creationContext) {
|
||||||
if ( hasFormulaProperties() ) {
|
if ( hasFormulaProperties() ) {
|
||||||
// we need to evaluate formulas in the database
|
// we need to evaluate formulas in the database
|
||||||
return true;
|
return true;
|
||||||
|
@ -1112,7 +1120,7 @@ public abstract class AbstractEntityPersister
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isCacheComplianceEnabled(PersisterCreationContext creationContext) {
|
private boolean isCacheComplianceEnabled(RuntimeModelCreationContext creationContext) {
|
||||||
return creationContext.getSessionFactory()
|
return creationContext.getSessionFactory()
|
||||||
.getSessionFactoryOptions()
|
.getSessionFactoryOptions()
|
||||||
.getJpaCompliance()
|
.getJpaCompliance()
|
||||||
|
|
|
@ -85,7 +85,7 @@ import org.hibernate.type.descriptor.java.VersionJavaType;
|
||||||
* for any natural id defined for this entity
|
* for any natural id defined for this entity
|
||||||
* </li>
|
* </li>
|
||||||
* <li>
|
* <li>
|
||||||
* {@link org.hibernate.persister.spi.PersisterCreationContext} -
|
* {@link org.hibernate.metamodel.spi.RuntimeModelCreationContext} -
|
||||||
* access to additional information useful while constructing the
|
* access to additional information useful while constructing the
|
||||||
* persister.
|
* persister.
|
||||||
* </li>
|
* </li>
|
||||||
|
@ -503,7 +503,9 @@ public interface EntityPersister
|
||||||
* @deprecated Use {@link #load(Object, Object, LockMode, SharedSessionContractImplementor)}
|
* @deprecated Use {@link #load(Object, Object, LockMode, SharedSessionContractImplementor)}
|
||||||
*/
|
*/
|
||||||
@Deprecated(since = "6.0")
|
@Deprecated(since = "6.0")
|
||||||
default Object load(Object id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session, Boolean readOnly)
|
default Object load(
|
||||||
|
Object id, Object optionalObject, LockMode lockMode, SharedSessionContractImplementor session,
|
||||||
|
@SuppressWarnings("unused") Boolean readOnly)
|
||||||
throws HibernateException {
|
throws HibernateException {
|
||||||
return load( id, optionalObject, lockMode, session );
|
return load( id, optionalObject, lockMode, session );
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,6 +49,7 @@ import org.hibernate.metamodel.mapping.internal.BasicEntityIdentifierMappingImpl
|
||||||
import org.hibernate.metamodel.mapping.internal.CaseStatementDiscriminatorMappingImpl;
|
import org.hibernate.metamodel.mapping.internal.CaseStatementDiscriminatorMappingImpl;
|
||||||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper;
|
import org.hibernate.metamodel.mapping.internal.MappingModelCreationHelper;
|
||||||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.query.spi.NavigablePath;
|
import org.hibernate.query.spi.NavigablePath;
|
||||||
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
import org.hibernate.query.sqm.function.SqmFunctionRegistry;
|
||||||
|
@ -157,11 +158,21 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
|
|
||||||
//INITIALIZATION:
|
//INITIALIZATION:
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public JoinedSubclassEntityPersister(
|
public JoinedSubclassEntityPersister(
|
||||||
final PersistentClass persistentClass,
|
final PersistentClass persistentClass,
|
||||||
final EntityDataAccess cacheAccessStrategy,
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
final PersisterCreationContext creationContext) throws HibernateException {
|
final PersisterCreationContext creationContext) throws HibernateException {
|
||||||
|
this( persistentClass,cacheAccessStrategy,naturalIdRegionAccessStrategy,
|
||||||
|
(RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public JoinedSubclassEntityPersister(
|
||||||
|
final PersistentClass persistentClass,
|
||||||
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
|
final RuntimeModelCreationContext creationContext) throws HibernateException {
|
||||||
|
|
||||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.hibernate.mapping.Selectable;
|
||||||
import org.hibernate.mapping.Subclass;
|
import org.hibernate.mapping.Subclass;
|
||||||
import org.hibernate.mapping.Table;
|
import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.mapping.Value;
|
import org.hibernate.mapping.Value;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.query.sqm.ComparisonOperator;
|
import org.hibernate.query.sqm.ComparisonOperator;
|
||||||
import org.hibernate.query.spi.NavigablePath;
|
import org.hibernate.query.spi.NavigablePath;
|
||||||
|
@ -132,11 +133,21 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
||||||
|
|
||||||
//INITIALIZATION:
|
//INITIALIZATION:
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public SingleTableEntityPersister(
|
public SingleTableEntityPersister(
|
||||||
final PersistentClass persistentClass,
|
final PersistentClass persistentClass,
|
||||||
final EntityDataAccess cacheAccessStrategy,
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
final PersisterCreationContext creationContext) throws HibernateException {
|
final PersisterCreationContext creationContext) throws HibernateException {
|
||||||
|
this( persistentClass,cacheAccessStrategy,naturalIdRegionAccessStrategy,
|
||||||
|
(RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public SingleTableEntityPersister(
|
||||||
|
final PersistentClass persistentClass,
|
||||||
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
|
final RuntimeModelCreationContext creationContext) throws HibernateException {
|
||||||
|
|
||||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.hibernate.mapping.Table;
|
||||||
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
|
import org.hibernate.metamodel.mapping.EntityDiscriminatorMapping;
|
||||||
import org.hibernate.metamodel.mapping.SelectableMapping;
|
import org.hibernate.metamodel.mapping.SelectableMapping;
|
||||||
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
import org.hibernate.metamodel.mapping.internal.MappingModelCreationProcess;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.query.spi.NavigablePath;
|
import org.hibernate.query.spi.NavigablePath;
|
||||||
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
import org.hibernate.sql.ast.spi.FromClauseAccess;
|
||||||
|
@ -88,11 +89,21 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
||||||
|
|
||||||
//INITIALIZATION:
|
//INITIALIZATION:
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public UnionSubclassEntityPersister(
|
public UnionSubclassEntityPersister(
|
||||||
final PersistentClass persistentClass,
|
final PersistentClass persistentClass,
|
||||||
final EntityDataAccess cacheAccessStrategy,
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
final PersisterCreationContext creationContext) throws HibernateException {
|
final PersisterCreationContext creationContext) throws HibernateException {
|
||||||
|
this( persistentClass,cacheAccessStrategy,naturalIdRegionAccessStrategy,
|
||||||
|
(RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnionSubclassEntityPersister(
|
||||||
|
final PersistentClass persistentClass,
|
||||||
|
final EntityDataAccess cacheAccessStrategy,
|
||||||
|
final NaturalIdDataAccess naturalIdRegionAccessStrategy,
|
||||||
|
final RuntimeModelCreationContext creationContext) throws HibernateException {
|
||||||
|
|
||||||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||||
|
|
||||||
|
|
|
@ -15,12 +15,11 @@ import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementHelper;
|
||||||
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
import org.hibernate.engine.spi.SessionFactoryImplementor;
|
||||||
import org.hibernate.id.IdentifierGenerator;
|
import org.hibernate.id.IdentifierGenerator;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
import org.hibernate.mapping.KeyValue;
|
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.metamodel.RepresentationMode;
|
import org.hibernate.metamodel.RepresentationMode;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
|
||||||
import org.hibernate.property.access.spi.Getter;
|
import org.hibernate.property.access.spi.Getter;
|
||||||
import org.hibernate.property.access.spi.PropertyAccess;
|
import org.hibernate.property.access.spi.PropertyAccess;
|
||||||
import org.hibernate.property.access.spi.PropertyAccessStrategy;
|
import org.hibernate.property.access.spi.PropertyAccessStrategy;
|
||||||
|
@ -54,7 +53,6 @@ public final class PropertyFactory {
|
||||||
public static IdentifierProperty buildIdentifierAttribute(
|
public static IdentifierProperty buildIdentifierAttribute(
|
||||||
PersistentClass mappedEntity,
|
PersistentClass mappedEntity,
|
||||||
IdentifierGenerator generator) {
|
IdentifierGenerator generator) {
|
||||||
String mappedUnsavedValue = mappedEntity.getIdentifier().getNullValue();
|
|
||||||
Type type = mappedEntity.getIdentifier().getType();
|
Type type = mappedEntity.getIdentifier().getType();
|
||||||
Property property = mappedEntity.getIdentifierProperty();
|
Property property = mappedEntity.getIdentifierProperty();
|
||||||
|
|
||||||
|
@ -92,7 +90,6 @@ public final class PropertyFactory {
|
||||||
int attributeNumber,
|
int attributeNumber,
|
||||||
Property property,
|
Property property,
|
||||||
boolean lazyAvailable) {
|
boolean lazyAvailable) {
|
||||||
String mappedUnsavedValue = ( (KeyValue) property.getValue() ).getNullValue();
|
|
||||||
|
|
||||||
boolean lazy = lazyAvailable && property.isLazy();
|
boolean lazy = lazyAvailable && property.isLazy();
|
||||||
|
|
||||||
|
@ -115,7 +112,7 @@ public final class PropertyFactory {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum NonIdentifierAttributeNature {
|
public enum NonIdentifierAttributeNature {
|
||||||
BASIC,
|
BASIC,
|
||||||
COMPOSITE,
|
COMPOSITE,
|
||||||
ANY,
|
ANY,
|
||||||
|
@ -137,7 +134,7 @@ public final class PropertyFactory {
|
||||||
int attributeNumber,
|
int attributeNumber,
|
||||||
Property property,
|
Property property,
|
||||||
boolean lazyAvailable,
|
boolean lazyAvailable,
|
||||||
PersisterCreationContext creationContext) {
|
RuntimeModelCreationContext creationContext) {
|
||||||
final Type type = property.getValue().getType();
|
final Type type = property.getValue().getType();
|
||||||
|
|
||||||
final NonIdentifierAttributeNature nature = decode( type );
|
final NonIdentifierAttributeNature nature = decode( type );
|
||||||
|
@ -149,14 +146,14 @@ public final class PropertyFactory {
|
||||||
// to update the cache (not the database), since in this case a null
|
// to update the cache (not the database), since in this case a null
|
||||||
// entity reference can lose information
|
// entity reference can lose information
|
||||||
|
|
||||||
boolean alwaysDirtyCheck = type.isAssociationType() &&
|
boolean alwaysDirtyCheck = type.isAssociationType()
|
||||||
( (AssociationType) type ).isAlwaysDirtyChecked();
|
&& ( (AssociationType) type ).isAlwaysDirtyChecked();
|
||||||
|
|
||||||
SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
SessionFactoryOptions sessionFactoryOptions = sessionFactory.getSessionFactoryOptions();
|
||||||
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
|
final boolean lazy = ! EnhancementHelper.includeInBaseFetchGroup(
|
||||||
property,
|
property,
|
||||||
lazyAvailable,
|
lazyAvailable,
|
||||||
(entityName) -> {
|
entityName -> {
|
||||||
final MetadataImplementor metadata = creationContext.getMetadata();
|
final MetadataImplementor metadata = creationContext.getMetadata();
|
||||||
final PersistentClass entityBinding = metadata.getEntityBinding( entityName );
|
final PersistentClass entityBinding = metadata.getEntityBinding( entityName );
|
||||||
assert entityBinding != null;
|
assert entityBinding != null;
|
||||||
|
@ -269,8 +266,8 @@ public final class PropertyFactory {
|
||||||
// to update the cache (not the database), since in this case a null
|
// to update the cache (not the database), since in this case a null
|
||||||
// entity reference can lose information
|
// entity reference can lose information
|
||||||
|
|
||||||
boolean alwaysDirtyCheck = type.isAssociationType() &&
|
boolean alwaysDirtyCheck = type.isAssociationType()
|
||||||
( (AssociationType) type ).isAlwaysDirtyChecked();
|
&& ( (AssociationType) type ).isAlwaysDirtyChecked();
|
||||||
|
|
||||||
return new StandardProperty(
|
return new StandardProperty(
|
||||||
property.getName(),
|
property.getName(),
|
||||||
|
@ -290,7 +287,7 @@ public final class PropertyFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static Constructor getConstructor(PersistentClass persistentClass) {
|
private static Constructor<?> getConstructor(PersistentClass persistentClass) {
|
||||||
if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
|
if ( persistentClass == null || !persistentClass.hasPojoRepresentation() ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ package org.hibernate.tuple.entity;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.hibernate.LockMode;
|
import org.hibernate.LockMode;
|
||||||
|
import org.hibernate.boot.Metadata;
|
||||||
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
|
import org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor;
|
||||||
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
import org.hibernate.bytecode.enhance.spi.interceptor.EnhancementAsProxyLazinessInterceptor;
|
||||||
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
|
import org.hibernate.bytecode.enhance.spi.interceptor.LazyAttributeLoadingInterceptor;
|
||||||
|
@ -24,7 +25,6 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||||
import org.hibernate.engine.spi.Status;
|
import org.hibernate.engine.spi.Status;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
|
||||||
import org.hibernate.type.CompositeType;
|
import org.hibernate.type.CompositeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,11 +39,11 @@ public final class BytecodeEnhancementMetadataPojoImpl implements BytecodeEnhanc
|
||||||
Set<String> identifierAttributeNames,
|
Set<String> identifierAttributeNames,
|
||||||
CompositeType nonAggregatedCidMapper,
|
CompositeType nonAggregatedCidMapper,
|
||||||
boolean collectionsInDefaultFetchGroupEnabled,
|
boolean collectionsInDefaultFetchGroupEnabled,
|
||||||
PersisterCreationContext creationContext) {
|
Metadata metadata) {
|
||||||
final Class<?> mappedClass = persistentClass.getMappedClass();
|
final Class<?> mappedClass = persistentClass.getMappedClass();
|
||||||
final boolean enhancedForLazyLoading = PersistentAttributeInterceptable.class.isAssignableFrom( mappedClass );
|
final boolean enhancedForLazyLoading = PersistentAttributeInterceptable.class.isAssignableFrom( mappedClass );
|
||||||
final LazyAttributesMetadata lazyAttributesMetadata = enhancedForLazyLoading
|
final LazyAttributesMetadata lazyAttributesMetadata = enhancedForLazyLoading
|
||||||
? LazyAttributesMetadata.from( persistentClass, true, collectionsInDefaultFetchGroupEnabled, creationContext )
|
? LazyAttributesMetadata.from( persistentClass, true, collectionsInDefaultFetchGroupEnabled, metadata )
|
||||||
: LazyAttributesMetadata.nonEnhanced( persistentClass.getEntityName() );
|
: LazyAttributesMetadata.nonEnhanced( persistentClass.getEntityName() );
|
||||||
|
|
||||||
return new BytecodeEnhancementMetadataPojoImpl(
|
return new BytecodeEnhancementMetadataPojoImpl(
|
||||||
|
|
|
@ -12,7 +12,6 @@ import java.util.BitSet;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -36,6 +35,7 @@ import org.hibernate.mapping.Component;
|
||||||
import org.hibernate.mapping.PersistentClass;
|
import org.hibernate.mapping.PersistentClass;
|
||||||
import org.hibernate.mapping.Property;
|
import org.hibernate.mapping.Property;
|
||||||
import org.hibernate.mapping.Subclass;
|
import org.hibernate.mapping.Subclass;
|
||||||
|
import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
|
||||||
import org.hibernate.persister.entity.EntityPersister;
|
import org.hibernate.persister.entity.EntityPersister;
|
||||||
import org.hibernate.persister.spi.PersisterCreationContext;
|
import org.hibernate.persister.spi.PersisterCreationContext;
|
||||||
import org.hibernate.tuple.GenerationTiming;
|
import org.hibernate.tuple.GenerationTiming;
|
||||||
|
@ -129,10 +129,18 @@ public class EntityMetamodel implements Serializable {
|
||||||
|
|
||||||
private final BytecodeEnhancementMetadata bytecodeEnhancementMetadata;
|
private final BytecodeEnhancementMetadata bytecodeEnhancementMetadata;
|
||||||
|
|
||||||
|
@Deprecated(since = "6.0")
|
||||||
public EntityMetamodel(
|
public EntityMetamodel(
|
||||||
PersistentClass persistentClass,
|
PersistentClass persistentClass,
|
||||||
EntityPersister persister,
|
EntityPersister persister,
|
||||||
PersisterCreationContext creationContext) {
|
PersisterCreationContext creationContext) {
|
||||||
|
this( persistentClass, persister, (RuntimeModelCreationContext) creationContext );
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityMetamodel(
|
||||||
|
PersistentClass persistentClass,
|
||||||
|
EntityPersister persister,
|
||||||
|
RuntimeModelCreationContext creationContext) {
|
||||||
this.sessionFactory = creationContext.getSessionFactory();
|
this.sessionFactory = creationContext.getSessionFactory();
|
||||||
|
|
||||||
name = persistentClass.getEntityName();
|
name = persistentClass.getEntityName();
|
||||||
|
@ -169,7 +177,7 @@ public class EntityMetamodel implements Serializable {
|
||||||
idAttributeNames,
|
idAttributeNames,
|
||||||
nonAggregatedCidMapper,
|
nonAggregatedCidMapper,
|
||||||
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled(),
|
sessionFactoryOptions.isCollectionsInDefaultFetchGroupEnabled(),
|
||||||
creationContext
|
creationContext.getMetadata()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -204,8 +212,6 @@ public class EntityMetamodel implements Serializable {
|
||||||
boolean foundPostUpdateGeneratedValues = false;
|
boolean foundPostUpdateGeneratedValues = false;
|
||||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
Iterator<Property> props = persistentClass.getPropertyClosureIterator();
|
|
||||||
int i = 0;
|
|
||||||
int tempVersionProperty = NO_VERSION_INDX;
|
int tempVersionProperty = NO_VERSION_INDX;
|
||||||
boolean foundCascade = false;
|
boolean foundCascade = false;
|
||||||
boolean foundCollection = false;
|
boolean foundCollection = false;
|
||||||
|
@ -213,8 +219,9 @@ public class EntityMetamodel implements Serializable {
|
||||||
boolean foundNonIdentifierPropertyNamedId = false;
|
boolean foundNonIdentifierPropertyNamedId = false;
|
||||||
boolean foundUpdateableNaturalIdProperty = false;
|
boolean foundUpdateableNaturalIdProperty = false;
|
||||||
|
|
||||||
while ( props.hasNext() ) {
|
List<Property> props = persistentClass.getPropertyClosure();
|
||||||
Property prop = props.next();
|
for ( int i=0; i<props.size(); i++ ) {
|
||||||
|
Property prop = props.get(i);
|
||||||
final NonIdentifierAttribute attribute;
|
final NonIdentifierAttribute attribute;
|
||||||
if ( prop == persistentClass.getVersion() ) {
|
if ( prop == persistentClass.getVersion() ) {
|
||||||
tempVersionProperty = i;
|
tempVersionProperty = i;
|
||||||
|
@ -333,7 +340,6 @@ public class EntityMetamodel implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
mapPropertyToIndex(prop, i);
|
mapPropertyToIndex(prop, i);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (naturalIdNumbers.size()==0) {
|
if (naturalIdNumbers.size()==0) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
*/
|
*/
|
||||||
public class PersisterTest extends BaseNonConfigCoreFunctionalTestCase {
|
public class PersisterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
@Test
|
@Test
|
||||||
public void testEntityEntityPersisterAndPersisterSpecified() throws Exception {
|
public void testEntityEntityPersisterAndPersisterSpecified() {
|
||||||
//checks to see that the persister specified with the @Persister annotation takes precedence if a @Entity.persister() is also specified
|
//checks to see that the persister specified with the @Persister annotation takes precedence if a @Entity.persister() is also specified
|
||||||
PersistentClass persistentClass = metadata().getEntityBinding( Deck.class.getName() );
|
PersistentClass persistentClass = metadata().getEntityBinding( Deck.class.getName() );
|
||||||
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(), EntityPersister.class,
|
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(), EntityPersister.class,
|
||||||
|
@ -28,7 +28,7 @@ public class PersisterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEntityEntityPersisterSpecified() throws Exception {
|
public void testEntityEntityPersisterSpecified() {
|
||||||
//tests the persister specified with an @Entity.persister()
|
//tests the persister specified with an @Entity.persister()
|
||||||
PersistentClass persistentClass = metadata().getEntityBinding( Card.class.getName() );
|
PersistentClass persistentClass = metadata().getEntityBinding( Card.class.getName() );
|
||||||
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(),
|
assertEquals( "Incorrect Persister class for " + persistentClass.getMappedClass(),
|
||||||
|
@ -36,7 +36,7 @@ public class PersisterTest extends BaseNonConfigCoreFunctionalTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCollectionPersisterSpecified() throws Exception {
|
public void testCollectionPersisterSpecified() {
|
||||||
//tests the persister specified by the @Persister annotation on a collection
|
//tests the persister specified by the @Persister annotation on a collection
|
||||||
Collection collection = metadata().getCollectionBinding( Deck.class.getName() + ".cards" );
|
Collection collection = metadata().getCollectionBinding( Deck.class.getName() + ".cards" );
|
||||||
assertEquals( "Incorrect Persister class for collection " + collection.getRole(), CollectionPersister.class,
|
assertEquals( "Incorrect Persister class for collection " + collection.getRole(), CollectionPersister.class,
|
||||||
|
|
Loading…
Reference in New Issue