Class NaturalIdLoadAccessImpl<T>
- All Implemented Interfaces:
NaturalIdLoadOptions,NaturalIdLoadAccess<T>
NaturalIdLoadAccess.-
Field Summary
Fields inherited from interface org.hibernate.loader.ast.spi.NaturalIdLoadOptions
NONE -
Constructor Summary
ConstructorsConstructorDescriptionNaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor) -
Method Summary
Modifier and TypeMethodDescriptiondisableFetchProfile(String profileName) Customize the associations fetched by specifying a fetch profile that should be disabled during this operation.enableFetchProfile(String profileName) Customize the associations fetched by specifying a fetch profile that should be enabled during this operation.final TReturn the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X).final Tload()Return the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X), ornullif there is no such persistent instance.Just likeNaturalIdLoadAccess.load(), except that here anOptionalis returned.setSynchronizationEnabled(boolean synchronizationEnabled) Determines if cached natural id cross-references are synchronized before query execution with unflushed modifications made in memory to mutable natural ids.<X> NaturalIdLoadAccess<T> using(SingularAttribute<? super T, X> attribute, X value) Add a@NaturalIdattribute value in a typesafe way.Add a@NaturalIdattribute value.Set multiple@NaturalIdattribute values at once.with(EntityGraph<T> graph, GraphSemantic semantic) Customize the associations fetched by specifying an entity graph, and how it should be interpreted.Specify the timeout to use when querying the database.with(LockMode lockMode, PessimisticLockScope lockScope) Specify the lock mode to use when querying the database.with(LockOptions lockOptions) Specify the lock options to use when querying the database.Methods inherited from class org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl
doGetReference, doLoad, entityPersister, getContext, getEntityDescriptor, getLockOptions, identifierLoadAccess, isSynchronizationEnabled, synchronizationEnabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.NaturalIdLoadAccess
with, withFetchGraph, withLoadGraph
-
Constructor Details
-
NaturalIdLoadAccessImpl
-
-
Method Details
-
with
Description copied from interface:NaturalIdLoadAccessSpecify the lock mode to use when querying the database.- Specified by:
within interfaceNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
lockMode- The lock mode to apply- Returns:
this, for method chaining
-
with
Description copied from interface:NaturalIdLoadAccessSpecify the timeout to use when querying the database.- Specified by:
within interfaceNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
timeout- The timeout to apply to the database operation- Returns:
this, for method chaining
-
with
Description copied from interface:NaturalIdLoadAccessSpecify the lock options to use when querying the database.- Specified by:
within interfaceNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
lockOptions- The lock options to use.- Returns:
this, for method chaining
-
using
Description copied from interface:NaturalIdLoadAccessAdd a@NaturalIdattribute value in a typesafe way.- Specified by:
usingin interfaceNaturalIdLoadAccess<T>- Parameters:
attribute- A typesafe reference to an attribute of the entity that is annotated@NaturalIdvalue- The value of the attribute- Returns:
this, for method chaining
-
using
Description copied from interface:NaturalIdLoadAccessAdd a@NaturalIdattribute value.- Specified by:
usingin interfaceNaturalIdLoadAccess<T>- Parameters:
attributeName- The name of an attribute of the entity that is annotated@NaturalIdvalue- The value of the attribute- Returns:
this, for method chaining
-
using
Description copied from interface:NaturalIdLoadAccessSet multiple@NaturalIdattribute values at once. An even number of arguments is expected, with each attribute name followed by its value, for example:Book book = session.byNaturalId(Book.class) .using(Map.of(Book_.ISBN, isbn, Book_.PRINTING, printing)) .load();- Specified by:
usingin interfaceNaturalIdLoadAccess<T>- Returns:
this, for method chaining
-
setSynchronizationEnabled
Description copied from interface:NaturalIdLoadAccessDetermines if cached natural id cross-references are synchronized before query execution with unflushed modifications made in memory to mutable natural ids.By default, every cached cross-reference is updated to reflect any modification made in memory.
Here "synchronization" means updating the natural id to primary key cross-reference maintained by the session. When enabled, before performing the lookup, Hibernate will check all entities associated with the session of the given type to determine if any natural id values have changed and, if so, update the cross-references.
There's some cost associated with this synchronization, so if it's completely certain the no natural ids have been modified, synchronization may be safely disabled to avoid that cost. Disabling this setting when natural id values have been modified may lead to incorrect results.
- Specified by:
setSynchronizationEnabledin interfaceNaturalIdLoadAccess<T>- Parameters:
synchronizationEnabled- Should synchronization be performed?trueindicates synchronization will be performed;falseindicates it will be circumvented.- Returns:
this, for method chaining
-
getReference
Description copied from interface:NaturalIdLoadAccessReturn the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X). This method might return a proxied instance that is initialized on-demand, when a non-identifier method is accessed.You should not use this method to determine if an instance exists; to check for existence, use
NaturalIdLoadAccess.load()instead. Use this method only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
getReferencein interfaceNaturalIdLoadAccess<T>- Returns:
- the persistent instance or proxy
-
load
Description copied from interface:NaturalIdLoadAccessReturn the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X), ornullif there is no such persistent instance. If the instance is already associated with the session, return that instance, initializing it if needed. This method never returns an uninitialized instance.- Specified by:
loadin interfaceNaturalIdLoadAccess<T>- Returns:
- The persistent instance or
null
-
loadOptional
Description copied from interface:NaturalIdLoadAccessJust likeNaturalIdLoadAccess.load(), except that here anOptionalis returned.- Specified by:
loadOptionalin interfaceNaturalIdLoadAccess<T>- Returns:
- The persistent instance, if one, as an
Optional
-
with
Description copied from interface:NaturalIdLoadAccessCustomize the associations fetched by specifying an entity graph, and how it should be interpreted.- Specified by:
within interfaceNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>
-
enableFetchProfile
Description copied from interface:NaturalIdLoadAccessCustomize the associations fetched by specifying a fetch profile that should be enabled during this operation.This allows the session-level fetch profiles to be temporarily overridden.
- Specified by:
enableFetchProfilein interfaceNaturalIdLoadAccess<T>- Overrides:
enableFetchProfilein classBaseNaturalIdLoadAccessImpl<T>
-
disableFetchProfile
Description copied from interface:NaturalIdLoadAccessCustomize the associations fetched by specifying a fetch profile that should be disabled during this operation.This allows the session-level fetch profiles to be temporarily overridden.
- Specified by:
disableFetchProfilein interfaceNaturalIdLoadAccess<T>- Overrides:
disableFetchProfilein classBaseNaturalIdLoadAccessImpl<T>
-