api, spi, internal, deprecation, javadoc

This commit is contained in:
Steve Ebersole 2022-01-24 16:04:08 -06:00
parent 510ce500f6
commit 521209815f
25 changed files with 86 additions and 49 deletions

View File

@ -9,9 +9,18 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.graph.Fetchable;
/**
* Commonality for an association, mainly details relative to the foreign-key
*
* @author Steve Ebersole
*/
public interface Association extends Fetchable {
/**
* The descriptor, allowing access to column(s), etc
*/
ForeignKeyDescriptor getForeignKeyDescriptor();
/**
* Indicates which "side" of the foreign-key this association describes
*/
ForeignKeyDescriptor.Nature getSideNature();
}

View File

@ -9,6 +9,13 @@ package org.hibernate.metamodel.mapping;
import java.util.List;
/**
* Used as part of circularity detection
* <p/>
* Uniquely distinguishes a side of the foreign-key, using
* that side's table and column(s)
*
* @see Association#resolveCircularFetch
*
* @author Andrea Boriero
*/
public class AssociationKey {

View File

@ -6,8 +6,6 @@
*/
package org.hibernate.metamodel.mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.property.access.spi.PropertyAccess;
import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.tuple.ValueGeneration;
@ -20,6 +18,9 @@ import org.hibernate.type.descriptor.java.MutabilityPlanExposer;
* @author Steve Ebersole
*/
public interface AttributeMapping extends ModelPart, ValueMapping, Fetchable, PropertyBasedMapping, MutabilityPlanExposer {
/**
* The name of the mapped attribute
*/
String getAttributeName();
@Override
@ -27,8 +28,14 @@ public interface AttributeMapping extends ModelPart, ValueMapping, Fetchable, Pr
return getAttributeName();
}
/**
* Access to AttributeMetadata
*/
AttributeMetadataAccess getAttributeMetadataAccess();
/**
* The managed type that declares this attribute
*/
ManagedMappingType getDeclaringType();
/**
@ -37,12 +44,15 @@ public interface AttributeMapping extends ModelPart, ValueMapping, Fetchable, Pr
PropertyAccess getPropertyAccess();
/**
* Convenient access to getting the value for this attribute from the "owner"
* Convenient access to getting the value for this attribute from the declarer
*/
default Object getValue(Object container) {
return getPropertyAccess().getGetter().get( container );
}
/**
* Convenient access to setting the value for this attribute on the declarer
*/
default void setValue(Object container, Object value) {
getPropertyAccess().getSetter().set( container, value );
}

View File

@ -9,6 +9,8 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.metamodel.mapping.internal.SingleAttributeIdentifierMapping;
/**
* Mapping for a simple identifier
*
* @author Steve Ebersole
*/
public interface BasicEntityIdentifierMapping extends SingleAttributeIdentifierMapping, BasicValuedModelPart {

View File

@ -10,13 +10,11 @@ import java.util.Collections;
import java.util.List;
/**
* Any basic-typed ValueMapping - e.g. a basic-valued singular attribute or a
* basic-valued collection element
*
* todo (6.0) : better to use {@link org.hibernate.metamodel.relational.Identifier} instead to handle quoting?
*
* todo (6.0) : expose {@link org.hibernate.metamodel.model.convert.spi.BasicValueConverter}?
* - Or just handle internal to impl?
* Any basic-typed ValueMapping. Generally this would be one of<ul>
* <li>a {@link jakarta.persistence.Basic} attribute</li>
* <li>a basic-valued collection part</li>
* <li>a {@link org.hibernate.type.BasicType}</li>
* </ul>
*
* @author Steve Ebersole
*/

View File

@ -9,6 +9,11 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.graph.Fetchable;
/**
* Describes a ModelPart which is a basic value, either<ul>
* <li>a {@link jakarta.persistence.Basic} attribute</li>
* <li>a basic-valued collection part</li>
* </ul>
*
* @author Steve Ebersole
*/
public interface BasicValuedModelPart extends BasicValuedMapping, ModelPart, Fetchable, SelectableMapping {

View File

@ -15,32 +15,13 @@ import org.hibernate.mapping.IndexedConsumer;
import org.hibernate.sql.ast.Clause;
/**
* Contract for things at the domain/mapping level that can be bound into a JDBC
* query.
*
* Notice that there may be more than one JDBC parameter involved here - an embedded value, e.g.
* Contract for things at the domain mapping level that can be bound
* into a JDBC {@link java.sql.PreparedStatement}.
*
* @author Steve Ebersole
*/
@Incubating
public interface Bindable extends JdbcMappingContainer {
/*
* todo (6.0) : much of this contract uses Clause which (1) kludgy and (2) not always necessary
* - e.g. see the note below wrt "2 forms of JDBC-type visiting"
*
* Instead, in keeping with the general shift away from the getter paradigm to a more functional (Consumer,
* Function, etc) paradigm, I propose something more like:
*
* interface Bindable {
* void apply(UpdateStatement sqlAst, ..., SqlAstCreationState creationState);
* void apply(DeleteStatement sqlAst, ..., SqlAstCreationState creationState);
*
* Expression toSqlAst(..., SqlAstCreationState creationState);
*
* // plus the `DomainResult`, `Fetch` (via `DomainResultProducer` and `Fetchable`)
* // handling most impls already provide
* }
*/
/**
* The number of JDBC mappings
@ -58,8 +39,6 @@ public interface Bindable extends JdbcMappingContainer {
return results;
}
// todo (6.0) : why did I do 2 forms of JDBC-type visiting? in-flight change?
/**
* Visit each of JdbcMapping
*
@ -152,8 +131,6 @@ public interface Bindable extends JdbcMappingContainer {
*
* Short-hand form of calling {@link #disassemble} and piping its result to
* {@link #forEachDisassembledJdbcValue}
*
* todo (6.0) : Would this would ever be used?
*/
default int forEachJdbcValue(
Object value,

View File

@ -9,8 +9,7 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.collection.spi.CollectionSemantics;
/**
* MappingType for collections. Not that this is the descriptor for
* the collection Java type (List, Set, etc)
* MappingType descriptor for the collection Java type (List, Set, etc)
*
* @author Steve Ebersole
*/

View File

@ -10,6 +10,13 @@ import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.type.descriptor.java.JavaTypedExpressible;
/**
* Hibernate understands mapping a collection into 4 parts<ol>
* <li>The key - the foreign-key defining the association to the owner</li>
* <li>The element - for Map's this is analogous to the value</li>
* <li>The index - the List/array index or Map key</li>
* <li>The collection-id - this is only relevant for id-bag mappings</li>
* </ol>
*
* @author Steve Ebersole
*/
public interface CollectionPart extends ModelPart, Fetchable, JavaTypedExpressible {

View File

@ -10,7 +10,7 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.engine.spi.IdentifierValue;
/**
* Support for composite identifier mappings
* Mapping for a composite identifier
*
* @author Andrea Boriero
*/

View File

@ -9,6 +9,8 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.metamodel.model.convert.spi.BasicValueConverter;
/**
* A BasicValuedModelPart which can have a converter associated with it
*
* @author Steve Ebersole
*/
public interface ConvertibleModelPart extends BasicValuedModelPart {

View File

@ -6,10 +6,8 @@
*/
package org.hibernate.metamodel.mapping;
import java.util.Map;
import java.util.function.Consumer;
import org.hibernate.Filter;
import org.hibernate.sql.ast.spi.SqlAstCreationState;
import org.hibernate.sql.ast.tree.from.TableGroup;
import org.hibernate.sql.ast.tree.predicate.Predicate;

View File

@ -18,6 +18,9 @@ import org.hibernate.sql.results.graph.FetchParent;
import org.hibernate.sql.results.graph.basic.BasicFetch;
/**
* @see jakarta.persistence.DiscriminatorColumn
* @see jakarta.persistence.DiscriminatorValue
*
* @author Steve Ebersole
*/
public interface EntityDiscriminatorMapping extends VirtualModelPart, BasicValuedModelPart, FetchOptions {

View File

@ -47,9 +47,9 @@ import org.hibernate.type.descriptor.java.JavaType;
import static org.hibernate.bytecode.enhance.spi.LazyPropertyInitializer.UNFETCHED_PROPERTY;
/**
* todo (6.0) : make this implement RootTableGroupProducer, etc instead of EntityPersister?
* Mapping of an entity
*
* todo (6.0) : leverage the "relational model" here?
* @see jakarta.persistence.Entity
*
* @author Steve Ebersole
*/

View File

@ -6,6 +6,11 @@
*/
package org.hibernate.metamodel.mapping;
/**
* Mapping of a row-id
*
* @see org.hibernate.annotations.RowId
*/
public interface EntityRowIdMapping extends VirtualModelPart {
String getRowIdName();
}

View File

@ -20,6 +20,13 @@ import org.hibernate.sql.results.graph.DomainResultCreationState;
import org.hibernate.sql.results.graph.FetchableContainer;
/**
* Entity-valued model part<ul>
* <li>{@link jakarta.persistence.ManyToOne}</li>
* <li>{@link jakarta.persistence.OneToOne}</li>
* <li>entity-valued collection element</li>
* <li>entity-valued Map key</li>
* </ul>
*
* @author Steve Ebersole
*/
public interface EntityValuedModelPart extends FetchableContainer {

View File

@ -12,6 +12,8 @@ import org.jboss.logging.Logger;
/**
* Logging related to natural-id operations
*
* @author Steve Ebersole
*/
public interface NaturalIdLogging {
String LOGGER_NAME = CoreLogging.subsystemLoggerName( "mapping.natural_id" );

View File

@ -15,6 +15,8 @@ import org.hibernate.loader.ast.spi.NaturalIdLoader;
/**
* Mapping for an entity's natural-id, if one is defined
*
* @author Steve Ebersole
*/
public interface NaturalIdMapping extends VirtualModelPart {
String PART_NAME = "{natural-id}";

View File

@ -26,6 +26,8 @@ import org.hibernate.sql.results.graph.embeddable.EmbeddableValuedFetchable;
*
* @see jakarta.persistence.IdClass
* @see jakarta.persistence.MapsId
*
* @author Steve Ebersole
*/
public interface NonAggregatedIdentifierMapping extends CompositeIdentifierMapping, EmbeddableValuedFetchable, FetchOptions, VirtualModelPart {
/**

View File

@ -24,6 +24,8 @@ import org.hibernate.sql.results.graph.Fetchable;
import org.hibernate.sql.results.graph.FetchableContainer;
/**
* Mapping of a plural (collection-valued) attribute
*
* @author Steve Ebersole
*/
public interface PluralAttributeMapping

View File

@ -15,10 +15,6 @@ import org.hibernate.boot.spi.SessionFactoryOptions;
* Defines a mapping model contract for things that can be queried in the HQL,
* Criteria, etc sense. Generally this
*
* todo (6.0) : consider whether collections are Queryable
* - depends how we envision Queryable being used. E.g. does it make
* sense to allow calls like `findSubPart( "index" )` or `findSubPart( "element" )`?
*
* @author Steve Ebersole
*/
public interface Queryable extends ModelPart {

View File

@ -7,6 +7,8 @@
package org.hibernate.metamodel.mapping;
/**
* Mapping for a singular (non-collection) attribute.
*
* @author Steve Ebersole
*/
public interface SingularAttributeMapping extends AttributeMapping, StateArrayContributorMapping {

View File

@ -10,8 +10,6 @@ package org.hibernate.metamodel.mapping;
* Unifying contract for things that are capable of being an expression in
* the SQL AST.
*
* todo (6.0) : consider adding `#toSqlExpression` returning a {@link org.hibernate.sql.ast.tree.expression.Expression}
*
* @author Steve Ebersole
*/
public interface SqlExpressible extends JdbcMappingContainer {

View File

@ -9,6 +9,10 @@ package org.hibernate.metamodel.mapping;
import org.hibernate.sql.results.graph.Fetchable;
/**
* Describes a model-part which contributes state to the array of values
* for a container it is part of. For example, an attribute contributes
* a value to the state array for its declarer
*
* @author Steve Ebersole
*/
public interface StateArrayContributorMapping extends AttributeMapping, Fetchable {

View File

@ -86,7 +86,7 @@ public abstract class AbstractEmbeddableMapping implements EmbeddableMappingType
final Object[] results = new Object[getNumberOfAttributeMappings()];
forEachAttributeMapping( (position, attribute) -> {
final Getter getter = attribute.getAttributeMetadataAccess()
.resolveAttributeMetadata( null )
.resolveAttributeMetadata( findContainingEntityMapping() )
.getPropertyAccess()
.getGetter();
results[position] = getter.get( compositeInstance );