clean up some warnings in persisters and improve javadoc
This commit is contained in:
parent
9724fb0d9b
commit
d4979ac547
|
@ -173,7 +173,7 @@ public interface SessionFactoryImplementor
|
|||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// map these to Metamodel
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("deprecation")
|
||||
MetamodelImplementor getMetamodel();
|
||||
|
||||
RootGraphImplementor<?> findEntityGraphByName(String name);
|
||||
|
|
|
@ -46,7 +46,9 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
*
|
||||
* @throws MappingException Indicates persister for that class could not be found.
|
||||
*/
|
||||
EntityPersister entityPersister(Class<?> entityClass);
|
||||
default EntityPersister entityPersister(Class<?> entityClass) {
|
||||
return getEntityDescriptor(entityClass);
|
||||
}
|
||||
|
||||
/**
|
||||
* Locate the persister for an entity by the entity-name
|
||||
|
@ -57,7 +59,9 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
*
|
||||
* @throws MappingException Indicates persister could not be found with that name.
|
||||
*/
|
||||
EntityPersister entityPersister(String entityName);
|
||||
default EntityPersister entityPersister(String entityName) {
|
||||
return getEntityDescriptor(entityName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all entity persisters as a Map, which entity name its the key and the persister is the value.
|
||||
|
@ -75,7 +79,9 @@ public interface MetamodelImplementor extends MappingMetamodel, Metamodel {
|
|||
*
|
||||
* @throws MappingException Indicates persister could not be found with that role.
|
||||
*/
|
||||
CollectionPersister collectionPersister(String role);
|
||||
default CollectionPersister collectionPersister(String role) {
|
||||
return getCollectionDescriptor(role);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all collection persisters as a Map, which collection role as the key and the persister is the value.
|
||||
|
|
|
@ -273,7 +273,7 @@ public abstract class AbstractCollectionPersister
|
|||
private final BasicValueConverter elementConverter;
|
||||
private final BasicValueConverter indexConverter;
|
||||
|
||||
// temprary
|
||||
// temporary
|
||||
private final JdbcMapping convertedElementType;
|
||||
private final JdbcMapping convertedIndexType;
|
||||
|
||||
|
@ -2158,21 +2158,17 @@ public abstract class AbstractCollectionPersister
|
|||
// TODO: formulas ?
|
||||
public void initCollectionPropertyMap() {
|
||||
|
||||
initCollectionPropertyMap( "key", keyType, keyColumnAliases, keyColumnNames );
|
||||
initCollectionPropertyMap( "element", elementType, elementColumnAliases, elementColumnNames );
|
||||
initCollectionPropertyMap( "key", keyType, keyColumnAliases );
|
||||
initCollectionPropertyMap( "element", elementType, elementColumnAliases );
|
||||
if ( hasIndex ) {
|
||||
initCollectionPropertyMap( "index", indexType, indexColumnAliases, indexColumnNames );
|
||||
initCollectionPropertyMap( "index", indexType, indexColumnAliases );
|
||||
}
|
||||
if ( hasIdentifier ) {
|
||||
initCollectionPropertyMap(
|
||||
"id",
|
||||
identifierType,
|
||||
new String[] { identifierColumnAlias },
|
||||
new String[] { identifierColumnName } );
|
||||
initCollectionPropertyMap( "id", identifierType, new String[] { identifierColumnAlias } );
|
||||
}
|
||||
}
|
||||
|
||||
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases, String[] columnNames) {
|
||||
private void initCollectionPropertyMap(String aliasName, Type type, String[] columnAliases) {
|
||||
|
||||
collectionPropertyColumnAliases.put( aliasName, columnAliases );
|
||||
|
||||
|
|
|
@ -33,7 +33,11 @@ import org.hibernate.sql.Update;
|
|||
import org.hibernate.sql.ast.tree.from.TableGroup;
|
||||
|
||||
/**
|
||||
* Collection persister for collections of values and many-to-many associations.
|
||||
* A {@link CollectionPersister} for {@linkplain jakarta.persistence.ElementCollection
|
||||
* collections of values} and {@linkplain jakarta.persistence.ManyToMany many-to-many
|
||||
* associations}.
|
||||
*
|
||||
* @see OneToManyPersister
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
|
|
|
@ -38,38 +38,52 @@ import org.hibernate.type.CollectionType;
|
|||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* A strategy for persisting a collection role. Defines a contract between
|
||||
* the persistence strategy and the actual persistent collection framework
|
||||
* and session. Does not define operations that are required for querying
|
||||
* collections, or loading by outer join.
|
||||
* A strategy for persisting a mapped collection role. A
|
||||
* {@code CollectionPersister} orchestrates rendering of SQL statements
|
||||
* corresponding to basic lifecycle events, including {@code insert},
|
||||
* {@code update}, and {@code delete} statements, and their execution via
|
||||
* JDBC.
|
||||
* <p>
|
||||
* Implements persistence of a collection instance while the instance is
|
||||
* referenced in a particular role.
|
||||
* Concrete implementations of this interface handle
|
||||
* {@linkplain OneToManyPersister one-to-many},
|
||||
* {@linkplain BasicCollectionPersister many-to-many}, association
|
||||
* cardinalities, and to a certain extent abstract the details of those
|
||||
* mappings from collaborators.
|
||||
* <p>
|
||||
* This class is highly coupled to the {@code PersistentCollection}
|
||||
* hierarchy, since double dispatch is used to load and update collection
|
||||
* elements.
|
||||
* Note that an instance of {@link PersistentCollection} may change roles.
|
||||
* This object implements persistence of a collection instance while the
|
||||
* instance is referenced in a particular role.
|
||||
* <p>
|
||||
* May be considered an immutable view of the mapping object
|
||||
* This interface defines a contract between the persistence strategy and
|
||||
* the actual {@linkplain PersistentCollection persistent collection framework}
|
||||
* and {@link org.hibernate.engine.spi.SessionImplementor session}. It does
|
||||
* not define operations that are required for querying collections, nor
|
||||
* for loading by outer join. Implementations are highly coupled to the
|
||||
* {@link PersistentCollection} hierarchy, since double dispatch is used to
|
||||
* load and update collection elements.
|
||||
* <p>
|
||||
* Unless a customer {@link org.hibernate.persister.spi.PersisterFactory} is used, it is expected
|
||||
* that implementations of CollectionDefinition define a constructor accepting the following arguments:
|
||||
* Unless a custom {@link org.hibernate.persister.spi.PersisterFactory} is
|
||||
* used, it is expected that implementations of {@link CollectionDefinition}
|
||||
* define a constructor accepting the following arguments:
|
||||
* <ol>
|
||||
* <li>
|
||||
* {@link org.hibernate.mapping.Collection} - The metadata about the collection to be handled
|
||||
* by the persister
|
||||
* {@link org.hibernate.mapping.Collection} - The metadata about
|
||||
* the collection to be handled by the persister,
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link CollectionDataAccess} - the second level caching strategy for this collection
|
||||
* {@link CollectionDataAccess} - the second level caching strategy
|
||||
* for this collection, and
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.persister.spi.PersisterCreationContext} - access to additional
|
||||
* information useful while constructing the persister.
|
||||
* {@link org.hibernate.persister.spi.PersisterCreationContext} -
|
||||
* access to additional information useful while constructing the
|
||||
* persister.
|
||||
* </li>
|
||||
* </ol>
|
||||
*
|
||||
* @see QueryableCollection
|
||||
* @see PersistentCollection
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
public interface CollectionPersister extends CollectionDefinition, Restrictable {
|
||||
|
|
|
@ -32,7 +32,10 @@ import org.hibernate.sql.ast.tree.from.TableGroup;
|
|||
import org.hibernate.sql.ast.tree.predicate.Predicate;
|
||||
|
||||
/**
|
||||
* Collection persister for one-to-many associations.
|
||||
* A {@link CollectionPersister} for {@link jakarta.persistence.OneToMany one-to-one
|
||||
* associations}.
|
||||
*
|
||||
* @see BasicCollectionPersister
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Brett Meyer
|
||||
|
|
|
@ -2089,10 +2089,6 @@ public abstract class AbstractEntityPersister
|
|||
return new GeneratedValuesProcessor( this, timing, getFactory() );
|
||||
}
|
||||
|
||||
protected interface InclusionChecker {
|
||||
boolean includeProperty(int propertyNumber);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object forceVersionIncrement(Object id, Object currentVersion, SharedSessionContractImplementor session) {
|
||||
if ( !isVersioned() ) {
|
||||
|
@ -2781,7 +2777,7 @@ public abstract class AbstractEntityPersister
|
|||
}
|
||||
}
|
||||
|
||||
private void initDiscriminatorPropertyPath(Mapping mapping) throws MappingException {
|
||||
private void initDiscriminatorPropertyPath() {
|
||||
propertyMapping.initPropertyPaths(
|
||||
ENTITY_CLASS,
|
||||
getDiscriminatorType(),
|
||||
|
@ -2798,7 +2794,7 @@ public abstract class AbstractEntityPersister
|
|||
initOrdinaryPropertyPaths( mapping ); //do two passes, for collection property-ref!
|
||||
initIdentifierPropertyPaths( mapping );
|
||||
if ( entityMetamodel.isPolymorphic() ) {
|
||||
initDiscriminatorPropertyPath( mapping );
|
||||
initDiscriminatorPropertyPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4092,11 +4088,7 @@ public abstract class AbstractEntityPersister
|
|||
// subclass ought to be joined by outer-join. However, TREAT-AS always requires that an inner-join be used
|
||||
// so we give TREAT-AS higher precedence...
|
||||
|
||||
if ( isSubclassTableIndicatedByTreatAsDeclarations( subclassTableNumber, treatAsDeclarations ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return isSubclassTableIndicatedByTreatAsDeclarations(subclassTableNumber, treatAsDeclarations);
|
||||
}
|
||||
|
||||
protected boolean isSubclassTableIndicatedByTreatAsDeclarations(
|
||||
|
@ -4340,7 +4332,7 @@ public abstract class AbstractEntityPersister
|
|||
@Override
|
||||
public boolean isAffectedByEnabledFilters(LoadQueryInfluencers loadQueryInfluencers) {
|
||||
if ( loadQueryInfluencers.hasEnabledFilters() && filterHelper != null ) {
|
||||
if ( filterHelper != null && filterHelper.isAffectedBy( loadQueryInfluencers.getEnabledFilters() ) ) {
|
||||
if ( filterHelper.isAffectedBy( loadQueryInfluencers.getEnabledFilters() ) ) {
|
||||
return true;
|
||||
}
|
||||
// we still need to verify collection fields to be eagerly loaded by 'join'
|
||||
|
@ -5883,7 +5875,6 @@ public abstract class AbstractEntityPersister
|
|||
@Override
|
||||
public void linkWithSubType(EntityMappingType sub, MappingModelCreationProcess creationProcess) {
|
||||
if ( subclassMappingTypes == null ) {
|
||||
//noinspection unchecked
|
||||
subclassMappingTypes = new TreeMap<>();
|
||||
}
|
||||
subclassMappingTypes.put( sub.getEntityName(), sub );
|
||||
|
@ -6037,7 +6028,6 @@ public abstract class AbstractEntityPersister
|
|||
int stateArrayPosition,
|
||||
MappingModelCreationProcess creationProcess) {
|
||||
final SessionFactoryImplementor sessionFactory = creationProcess.getCreationContext().getSessionFactory();
|
||||
final TypeConfiguration typeConfiguration = sessionFactory.getTypeConfiguration();
|
||||
final JdbcServices jdbcServices = sessionFactory.getJdbcServices();
|
||||
final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment();
|
||||
final Dialect dialect = jdbcEnvironment.getDialect();
|
||||
|
@ -6116,7 +6106,7 @@ public abstract class AbstractEntityPersister
|
|||
stateArrayPosition,
|
||||
bootProperty,
|
||||
this,
|
||||
(BasicType) attrType,
|
||||
(BasicType<?>) attrType,
|
||||
tableExpression,
|
||||
attrColumnExpression,
|
||||
isAttrColumnExpressionFormula,
|
||||
|
@ -6426,11 +6416,7 @@ public abstract class AbstractEntityPersister
|
|||
return true;
|
||||
}
|
||||
|
||||
if ( !entityMetamodel.hasNonIdentifierPropertyNamedId() && "id".equals( name ) ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return !entityMetamodel.hasNonIdentifierPropertyNamedId() && "id".equals( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6512,11 +6498,7 @@ public abstract class AbstractEntityPersister
|
|||
public void visitSubTypeAttributeMappings(Consumer<? super AttributeMapping> action) {
|
||||
visitAttributeMappings( action );
|
||||
if ( subclassMappingTypes != null ) {
|
||||
subclassMappingTypes.forEach(
|
||||
(s, subType) -> {
|
||||
subType.visitDeclaredAttributeMappings( action );
|
||||
}
|
||||
);
|
||||
subclassMappingTypes.forEach( (s, subType) -> subType.visitDeclaredAttributeMappings( action ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,29 +52,47 @@ import org.hibernate.type.Type;
|
|||
import org.hibernate.type.descriptor.java.VersionJavaType;
|
||||
|
||||
/**
|
||||
* Contract describing mapping information and persistence logic for a particular strategy of entity mapping. A given
|
||||
* persister instance corresponds to a given mapped entity class.
|
||||
* <p/>
|
||||
* Implementations must be thread-safe (preferably immutable).
|
||||
* <p/>
|
||||
* Unless a custom {@link org.hibernate.persister.spi.PersisterFactory} is used, it is expected
|
||||
* that implementations of EntityPersister define a constructor accepting the following arguments:<ol>
|
||||
* A strategy for persisting a mapped {@linkplain jakarta.persistence.Entity
|
||||
* entity class}. An {@code EntityPersister} orchestrates rendering of the
|
||||
* SQL statements corresponding to basic lifecycle events, including
|
||||
* {@code insert}, {@code update}, and {@code delete} statements, and their
|
||||
* execution via JDBC.
|
||||
* <p>
|
||||
* Concrete implementations of this interface handle the
|
||||
* {@linkplain SingleTableEntityPersister single table},
|
||||
* {@linkplain JoinedSubclassEntityPersister joined}, and
|
||||
* {@linkplain UnionSubclassEntityPersister union} inheritance mapping
|
||||
* strategies, and to a certain extent abstract the details of those
|
||||
* mappings from collaborators.
|
||||
* <p>
|
||||
* This interface defines a contract between the persistence strategy and
|
||||
* the {@link org.hibernate.engine.spi.SessionImplementor session}. It does
|
||||
* not define operations that are required for querying, nor for loading by
|
||||
* outer join.
|
||||
* <p>
|
||||
* Unless a custom {@link org.hibernate.persister.spi.PersisterFactory} is
|
||||
* used, it is expected that implementations of {@code EntityPersister}
|
||||
* define a constructor accepting the following arguments:
|
||||
* <ol>
|
||||
* <li>
|
||||
* {@link org.hibernate.mapping.PersistentClass} - describes the metadata about the entity
|
||||
* to be handled by the persister
|
||||
* {@link org.hibernate.mapping.PersistentClass} - describes the
|
||||
* metadata about the entity to be handled by the persister
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link EntityDataAccess} - the second level caching strategy for this entity
|
||||
* {@link EntityDataAccess} - the second level caching strategy for
|
||||
* this entity
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link NaturalIdDataAccess} - the second level caching strategy for the natural-id
|
||||
* defined for this entity, if one
|
||||
* {@link NaturalIdDataAccess} - the second level caching strategy
|
||||
* for any natural id defined for this entity
|
||||
* </li>
|
||||
* <li>
|
||||
* {@link org.hibernate.persister.spi.PersisterCreationContext} - access to additional
|
||||
* information useful while constructing the persister.
|
||||
* {@link org.hibernate.persister.spi.PersisterCreationContext} -
|
||||
* access to additional information useful while constructing the
|
||||
* persister.
|
||||
* </li>
|
||||
* </ol>
|
||||
* Implementations must be thread-safe (and preferably immutable).
|
||||
*
|
||||
* @author Gavin King
|
||||
* @author Steve Ebersole
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.function.Supplier;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.model.relational.Database;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
|
@ -65,15 +64,21 @@ import org.hibernate.type.BasicType;
|
|||
import org.hibernate.type.CompositeType;
|
||||
import org.hibernate.type.StandardBasicTypes;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import static java.util.Collections.emptyMap;
|
||||
|
||||
/**
|
||||
* An {@code EntityPersister} implementing the normalized "table-per-subclass"
|
||||
* mapping strategy
|
||||
* An {@link EntityPersister} implementing the normalized
|
||||
* {@link jakarta.persistence.InheritanceType#JOINED} inheritance
|
||||
* mapping strategy for an entity and its inheritance hierarchy.
|
||||
* <p>
|
||||
* This is implemented as a separate table for each subclass,
|
||||
* with only declared attributes persisted as columns of that table.
|
||||
* Thus, each instance of a subclass has its state stored across
|
||||
* rows of multiple tables.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
|
@ -160,7 +165,6 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
super( persistentClass, cacheAccessStrategy, naturalIdRegionAccessStrategy, creationContext );
|
||||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
final Database database = creationContext.getMetadata().getDatabase();
|
||||
|
||||
// DISCRIMINATOR
|
||||
|
||||
|
@ -189,13 +193,15 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
else {
|
||||
try {
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor().fromString( persistentClass.getDiscriminatorValue() );
|
||||
discriminatorSQLString = discriminatorType.getJdbcType().getJdbcLiteralFormatter( (JavaType) discriminatorType.getJavaTypeDescriptor() )
|
||||
.toJdbcLiteral(
|
||||
discriminatorValue,
|
||||
factory.getJdbcServices().getDialect(),
|
||||
factory.getWrapperOptions()
|
||||
);
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor()
|
||||
.fromString( persistentClass.getDiscriminatorValue() );
|
||||
JdbcLiteralFormatter literalFormatter = discriminatorType.getJdbcType()
|
||||
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
||||
discriminatorSQLString = literalFormatter.toJdbcLiteral(
|
||||
discriminatorValue,
|
||||
factory.getJdbcServices().getDialect(),
|
||||
factory.getWrapperOptions()
|
||||
);
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
throw new MappingException("Illegal discriminator type: " + discriminatorType.getName() );
|
||||
|
|
|
@ -6,16 +6,11 @@
|
|||
*/
|
||||
package org.hibernate.persister.entity;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Implemented by a {@code EntityPersister} that may be loaded
|
||||
* using {@code Loader}.
|
||||
* Implemented by any {@link EntityPersister} that may be loaded
|
||||
* using a {@link org.hibernate.loader.ast.spi.Loader}.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
|
|
|
@ -5,17 +5,16 @@
|
|||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
||||
*/
|
||||
package org.hibernate.persister.entity;
|
||||
|
||||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.engine.spi.CascadeStyle;
|
||||
import org.hibernate.type.EntityType;
|
||||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* A {@code EntityPersister} that may be loaded by outer join using
|
||||
* the {@code OuterJoinLoader} hierarchy and may be an element
|
||||
* of a one-to-many association.
|
||||
* A {@link EntityPersister} that may be loaded by outer join using
|
||||
* and may be an element of a one-to-many association.
|
||||
*
|
||||
* @see org.hibernate.loader.OuterJoinLoader
|
||||
* @author Gavin King
|
||||
*/
|
||||
public interface OuterJoinLoadable extends Loadable, Joinable {
|
||||
|
|
|
@ -32,17 +32,17 @@ import org.hibernate.type.Type;
|
|||
*/
|
||||
public interface PropertyMapping {
|
||||
|
||||
/**
|
||||
* @asciidoc
|
||||
*
|
||||
* Resolve a sub-reference relative to this PropertyMapping. E.g.,
|
||||
* given the PropertyMapping for an entity named `Person` with an embedded
|
||||
* property `#name` calling this method with `"name"` returns the
|
||||
* PropertyMapping for the `Name` embeddable
|
||||
* <p>
|
||||
* todo (6.0) : define an exception in the signature for cases where the PropertyMapping
|
||||
* cannot be de-referenced (basic values)
|
||||
*/
|
||||
// /**
|
||||
// * @asciidoc
|
||||
// *
|
||||
// * Resolve a sub-reference relative to this PropertyMapping. E.g.,
|
||||
// * given the PropertyMapping for an entity named `Person` with an embedded
|
||||
// * property `#name` calling this method with `"name"` returns the
|
||||
// * PropertyMapping for the `Name` embeddable
|
||||
// * <p>
|
||||
// * todo (6.0) : define an exception in the signature for cases where the PropertyMapping
|
||||
// * cannot be de-referenced (basic values)
|
||||
// */
|
||||
// PropertyMapping resolveSubMapping(String name);
|
||||
|
||||
// todo (6.0) : add capability to create SqmPath, i.e.
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
package org.hibernate.persister.entity;
|
||||
|
||||
/**
|
||||
* Extends the generic {@code EntityPersister} contract to add
|
||||
* Extends the generic {@link EntityPersister} contract to add
|
||||
* operations required by the Hibernate Query Language
|
||||
*
|
||||
* @author Gavin King
|
||||
|
|
|
@ -5,11 +5,12 @@
|
|||
* 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.type.Type;
|
||||
|
||||
/**
|
||||
* A class persister that supports queries expressed in the
|
||||
* platform native SQL dialect
|
||||
* An {@link EntityPersister} that supports queries expressed
|
||||
* in the platform native SQL dialect.
|
||||
*
|
||||
* @author Gavin King, Max Andersen
|
||||
*/
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.function.Supplier;
|
|||
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.model.relational.Database;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
|
@ -63,14 +62,16 @@ import org.hibernate.sql.ast.tree.predicate.Predicate;
|
|||
import org.hibernate.type.AssociationType;
|
||||
import org.hibernate.type.BasicType;
|
||||
import org.hibernate.type.Type;
|
||||
import org.hibernate.type.descriptor.java.JavaType;
|
||||
import org.hibernate.type.descriptor.jdbc.JdbcLiteralFormatter;
|
||||
|
||||
/**
|
||||
* The default implementation of the {@code EntityPersister} interface.
|
||||
* Implements the "table-per-class-hierarchy" or "roll-up" mapping strategy
|
||||
* for an entity class and its inheritance hierarchy. This is implemented
|
||||
* as a single table holding all classes in the hierarchy with a discriminator
|
||||
* column used to determine which concrete class is referenced.
|
||||
* The default implementation of the {@link EntityPersister} interface.
|
||||
* Implements the {@link jakarta.persistence.InheritanceType#SINGLE_TABLE}
|
||||
* mapping strategy for an entity class and its inheritance hierarchy.
|
||||
* <p>
|
||||
* This is implemented as a single table for all classes of the hierarchy,
|
||||
* with a discriminator column used to determine which concrete class a
|
||||
* row represents.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
|
@ -142,8 +143,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
|
||||
final Database database = creationContext.getMetadata().getDatabase();
|
||||
|
||||
// CLASS + TABLE
|
||||
|
||||
joinSpan = persistentClass.getJoinClosureSpan() + 1;
|
||||
|
@ -240,7 +239,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
final boolean lazyAvailable = isInstrumented();
|
||||
|
||||
boolean hasDeferred = false;
|
||||
ArrayList<String> subclassTables = new ArrayList<>();
|
||||
ArrayList<String[]> joinKeyColumns = new ArrayList<>();
|
||||
ArrayList<Boolean> isConcretes = new ArrayList<>();
|
||||
|
@ -268,7 +266,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
|
||||
boolean isDeferred = join.isSequentialSelect() && ! persistentClass.isClassOrSuperclassJoin( join ) ;
|
||||
isDeferreds.add( isDeferred );
|
||||
hasDeferred |= isDeferred;
|
||||
|
||||
String joinTableName = determineTableName( join.getTable() );
|
||||
subclassTables.add( joinTableName );
|
||||
|
@ -339,13 +336,15 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
|
|||
else {
|
||||
discriminatorInsertable = persistentClass.isDiscriminatorInsertable() && !discrimValue.hasFormula();
|
||||
try {
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor().fromString( persistentClass.getDiscriminatorValue() );
|
||||
discriminatorSQLValue = discriminatorType.getJdbcType().getJdbcLiteralFormatter( (JavaType) discriminatorType.getJavaTypeDescriptor() )
|
||||
.toJdbcLiteral(
|
||||
discriminatorValue,
|
||||
factory.getJdbcServices().getDialect(),
|
||||
factory.getWrapperOptions()
|
||||
);
|
||||
discriminatorValue = discriminatorType.getJavaTypeDescriptor()
|
||||
.fromString( persistentClass.getDiscriminatorValue() );
|
||||
JdbcLiteralFormatter literalFormatter = discriminatorType.getJdbcType()
|
||||
.getJdbcLiteralFormatter( discriminatorType.getJavaTypeDescriptor() );
|
||||
discriminatorSQLValue = literalFormatter.toJdbcLiteral(
|
||||
discriminatorValue,
|
||||
factory.getJdbcServices().getDialect(),
|
||||
factory.getWrapperOptions()
|
||||
);
|
||||
}
|
||||
catch (ClassCastException cce) {
|
||||
throw new MappingException( "Illegal discriminator type: " + discriminatorType.getName() );
|
||||
|
|
|
@ -23,11 +23,9 @@ import java.util.function.Supplier;
|
|||
import org.hibernate.AssertionFailure;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.boot.model.relational.Database;
|
||||
import org.hibernate.boot.model.relational.SqlStringGenerationContext;
|
||||
import org.hibernate.cache.spi.access.EntityDataAccess;
|
||||
import org.hibernate.cache.spi.access.NaturalIdDataAccess;
|
||||
import org.hibernate.cfg.Settings;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.engine.spi.Mapping;
|
||||
|
@ -62,8 +60,12 @@ import org.hibernate.type.StandardBasicTypes;
|
|||
import org.hibernate.type.Type;
|
||||
|
||||
/**
|
||||
* Implementation of the "table-per-concrete-class" or "roll-down" mapping
|
||||
* strategy for an entity and its inheritance hierarchy.
|
||||
* An {@link EntityPersister} implementing the
|
||||
* {@link jakarta.persistence.InheritanceType#TABLE_PER_CLASS}
|
||||
* mapping strategy for an entity and its inheritance hierarchy.
|
||||
* <p>
|
||||
* This is implemented as a separate table for each concrete class,
|
||||
* with all inherited attributes persisted as columns of that table.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
|
@ -103,7 +105,6 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
}
|
||||
|
||||
final SessionFactoryImplementor factory = creationContext.getSessionFactory();
|
||||
final Database database = creationContext.getMetadata().getDatabase();
|
||||
|
||||
// TABLE
|
||||
|
||||
|
@ -112,8 +113,8 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
//Custom SQL
|
||||
|
||||
String sql;
|
||||
boolean callable = false;
|
||||
ExecuteUpdateResultCheckStyle checkStyle = null;
|
||||
boolean callable;
|
||||
ExecuteUpdateResultCheckStyle checkStyle;
|
||||
sql = persistentClass.getCustomSQLInsert();
|
||||
callable = sql != null && persistentClass.isCustomInsertCallable();
|
||||
checkStyle = sql == null
|
||||
|
@ -482,6 +483,7 @@ public class UnionSubclassEntityPersister extends AbstractEntityPersister {
|
|||
StringBuilder buf = new StringBuilder()
|
||||
.append( "( " );
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
Iterator<PersistentClass> siter = new JoinedIterator<>(
|
||||
new SingletonIterator<>( model ),
|
||||
model.getSubclassIterator()
|
||||
|
|
|
@ -9,6 +9,8 @@ package org.hibernate.persister.entity;
|
|||
import org.hibernate.engine.spi.SharedSessionContractImplementor;
|
||||
|
||||
/**
|
||||
* An {@link EntityPersister} that can be loaded by a non-primary unique key.
|
||||
*
|
||||
* @author Gavin King
|
||||
*/
|
||||
public interface UniqueKeyLoadable extends Loadable {
|
||||
|
|
Loading…
Reference in New Issue