Class AbstractNaturalIdLoader<T>
- java.lang.Object
-
- org.hibernate.loader.ast.internal.AbstractNaturalIdLoader<T>
-
- All Implemented Interfaces:
EntityLoader,Loader,MultiKeyLoader,NaturalIdLoader<T>
- Direct Known Subclasses:
CompoundNaturalIdLoader,SimpleNaturalIdLoader
public abstract class AbstractNaturalIdLoader<T> extends Object implements NaturalIdLoader<T>
Base support for NaturalIdLoader implementations
-
-
Constructor Summary
Constructors Constructor Description AbstractNaturalIdLoader(NaturalIdMapping naturalIdMapping, EntityMappingType entityDescriptor)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract voidapplyNaturalIdRestriction(Object bindValue, TableGroup rootTableGroup, Consumer<Predicate> predicateConsumer, BiConsumer<JdbcParameter,JdbcParameterBinding> jdbcParameterConsumer, LoaderSqlAstCreationState sqlAstCreationState, SharedSessionContractImplementor session)Apply restriction necessary to match the given natural-id value.protected EntityMappingTypeentityDescriptor()EntityMappingTypegetLoadable()The value-mapping loaded by this loaderTload(Object naturalIdValue, NaturalIdLoadOptions options, SharedSessionContractImplementor session)Perform the load of the entity by its natural-idprotected NaturalIdMappingnaturalIdMapping()protected ExpressionresolveColumnReference(TableGroup rootTableGroup, SelectableMapping selectableMapping, SqlExpressionResolver sqlExpressionResolver, SessionFactoryImplementor sessionFactory)Helper to resolve ColumnReferencesObjectresolveIdToNaturalId(Object id, SharedSessionContractImplementor session)Resolve the natural-id value(s) from an idObjectresolveNaturalIdToId(Object naturalIdValue, SharedSessionContractImplementor session)Resolve the id from natural-id valueprotected <L> LselectByNaturalId(Object bindValue, NaturalIdLoadOptions options, BiFunction<TableGroup,LoaderSqlAstCreationState,DomainResult<?>> domainResultProducer, LoaderSqlAstCreationState.FetchProcessor fetchProcessor, Function<Boolean,Long> statementStartHandler, BiConsumer<Object,Long> statementCompletionHandler, SharedSessionContractImplementor session)Perform a select, restricted by natural-id, based on `domainResultProducer` and `fetchProcessor`
-
-
-
Constructor Detail
-
AbstractNaturalIdLoader
public AbstractNaturalIdLoader(NaturalIdMapping naturalIdMapping, EntityMappingType entityDescriptor)
-
-
Method Detail
-
entityDescriptor
protected EntityMappingType entityDescriptor()
-
naturalIdMapping
protected NaturalIdMapping naturalIdMapping()
-
getLoadable
public EntityMappingType getLoadable()
Description copied from interface:LoaderThe value-mapping loaded by this loader- Specified by:
getLoadablein interfaceEntityLoader- Specified by:
getLoadablein interfaceLoader
-
load
public T load(Object naturalIdValue, NaturalIdLoadOptions options, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdLoaderPerform the load of the entity by its natural-id- Specified by:
loadin interfaceNaturalIdLoader<T>- Parameters:
naturalIdValue- The natural-id to load. One of 2 forms accepted: * Single-value - valid for entities with a simple (single-valued) natural-id * Map - valid for any natural-id load. The map is each value keyed by the attribute name that the value corresponds to. Even though this form is allowed for simple natural-ids, the single value form should be used as it is more efficientoptions- The options to apply to the load operationsession- The session into which the entity is being loaded
-
selectByNaturalId
protected <L> L selectByNaturalId(Object bindValue, NaturalIdLoadOptions options, BiFunction<TableGroup,LoaderSqlAstCreationState,DomainResult<?>> domainResultProducer, LoaderSqlAstCreationState.FetchProcessor fetchProcessor, Function<Boolean,Long> statementStartHandler, BiConsumer<Object,Long> statementCompletionHandler, SharedSessionContractImplementor session)
Perform a select, restricted by natural-id, based on `domainResultProducer` and `fetchProcessor`
-
applyNaturalIdRestriction
protected abstract void applyNaturalIdRestriction(Object bindValue, TableGroup rootTableGroup, Consumer<Predicate> predicateConsumer, BiConsumer<JdbcParameter,JdbcParameterBinding> jdbcParameterConsumer, LoaderSqlAstCreationState sqlAstCreationState, SharedSessionContractImplementor session)
Apply restriction necessary to match the given natural-id value. Should apply any predicates to `predicateConsumer` as well and any parameter / binding pairs
-
resolveColumnReference
protected Expression resolveColumnReference(TableGroup rootTableGroup, SelectableMapping selectableMapping, SqlExpressionResolver sqlExpressionResolver, SessionFactoryImplementor sessionFactory)
Helper to resolve ColumnReferences
-
resolveNaturalIdToId
public Object resolveNaturalIdToId(Object naturalIdValue, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdLoaderResolve the id from natural-id value- Specified by:
resolveNaturalIdToIdin interfaceNaturalIdLoader<T>
-
resolveIdToNaturalId
public Object resolveIdToNaturalId(Object id, SharedSessionContractImplementor session)
Description copied from interface:NaturalIdLoaderResolve the natural-id value(s) from an id- Specified by:
resolveIdToNaturalIdin interfaceNaturalIdLoader<T>
-
-