Class NaturalIdLoadAccessImpl<T>
- java.lang.Object
-
- org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl<T>
-
- org.hibernate.loader.internal.NaturalIdLoadAccessImpl<T>
-
- All Implemented Interfaces:
NaturalIdLoadOptions
,NaturalIdLoadAccess<T>
public class NaturalIdLoadAccessImpl<T> extends BaseNaturalIdLoadAccessImpl<T> implements NaturalIdLoadAccess<T>
-
-
Field Summary
-
Fields inherited from interface org.hibernate.loader.ast.spi.NaturalIdLoadOptions
NONE
-
-
Constructor Summary
Constructors Constructor Description NaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description NaturalIdLoadAccess<T>
disableFetchProfile(String profileName)
Customize the associations fetched by specifying a fetch profile that should be disabled during this operation.NaturalIdLoadAccess<T>
enableFetchProfile(String profileName)
Customize the associations fetched by specifying a fetch profile that should be enabled during this operation.T
getReference()
Return the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X)
.T
load()
Return the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X)
, ornull
if there is no such persistent instance.Optional<T>
loadOptional()
Just likeNaturalIdLoadAccess.load()
, except that here anOptional
is returned.NaturalIdLoadAccessImpl<T>
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@NaturalId
attribute value in a typesafe way.NaturalIdLoadAccess<T>
using(Object... mappings)
Deprecated.NaturalIdLoadAccess<T>
using(String attributeName, Object value)
Add a@NaturalId
attribute value.NaturalIdLoadAccess<T>
using(Map<String,?> mappings)
Set multiple@NaturalId
attribute values at once.NaturalIdLoadAccess<T>
with(RootGraph<T> graph, GraphSemantic semantic)
Customize the associations fetched by specifying an entity graph, and how it should be interpreted.NaturalIdLoadAccessImpl<T>
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, getIdentifierLoadAccess, getLockOptions, isSynchronizationEnabled, performAnyNeededCrossReferenceSynchronizations, synchronizationEnabled
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.NaturalIdLoadAccess
withFetchGraph, withLoadGraph
-
-
-
-
Constructor Detail
-
NaturalIdLoadAccessImpl
public NaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor)
-
-
Method Detail
-
with
public NaturalIdLoadAccessImpl<T> with(LockOptions lockOptions)
Description copied from interface:NaturalIdLoadAccess
Specify the lock options to use when querying the database.- Specified by:
with
in interfaceNaturalIdLoadAccess<T>
- Overrides:
with
in classBaseNaturalIdLoadAccessImpl<T>
- Parameters:
lockOptions
- The lock options to use.- Returns:
this
, for method chaining
-
using
public <X> NaturalIdLoadAccess<T> using(SingularAttribute<? super T,X> attribute, X value)
Description copied from interface:NaturalIdLoadAccess
Add a@NaturalId
attribute value in a typesafe way.- Specified by:
using
in interfaceNaturalIdLoadAccess<T>
- Parameters:
attribute
- A typesafe reference to an attribute of the entity that is annotated@NaturalId
value
- The value of the attribute- Returns:
this
, for method chaining
-
using
public NaturalIdLoadAccess<T> using(String attributeName, Object value)
Description copied from interface:NaturalIdLoadAccess
Add a@NaturalId
attribute value.- Specified by:
using
in interfaceNaturalIdLoadAccess<T>
- Parameters:
attributeName
- The name of an attribute of the entity that is annotated@NaturalId
value
- The value of the attribute- Returns:
this
, for method chaining
-
using
public NaturalIdLoadAccess<T> using(Map<String,?> mappings)
Description copied from interface:NaturalIdLoadAccess
Set multiple@NaturalId
attribute 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:
using
in interfaceNaturalIdLoadAccess<T>
- Returns:
this
, for method chaining
-
using
@Deprecated public NaturalIdLoadAccess<T> using(Object... mappings)
Deprecated.Description copied from interface:NaturalIdLoadAccess
Set multiple@NaturalId
attribute 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(Book_.ISBN, isbn, Book_.PRINTING, printing) .load();
- Specified by:
using
in interfaceNaturalIdLoadAccess<T>
- Returns:
this
, for method chaining
-
setSynchronizationEnabled
public NaturalIdLoadAccessImpl<T> setSynchronizationEnabled(boolean synchronizationEnabled)
Description copied from interface:NaturalIdLoadAccess
Determines 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:
setSynchronizationEnabled
in interfaceNaturalIdLoadAccess<T>
- Parameters:
synchronizationEnabled
- Should synchronization be performed?true
indicates synchronization will be performed;false
indicates it will be circumvented.- Returns:
this
, for method chaining
-
getReference
public final T getReference()
Description copied from interface:NaturalIdLoadAccess
Return 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:
getReference
in interfaceNaturalIdLoadAccess<T>
- Returns:
- the persistent instance or proxy
-
load
public final T load()
Description copied from interface:NaturalIdLoadAccess
Return the persistent instance with the full natural id specified by previous calls toNaturalIdLoadAccess.using(jakarta.persistence.metamodel.SingularAttribute<? super T, X>, X)
, ornull
if 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:
load
in interfaceNaturalIdLoadAccess<T>
- Returns:
- The persistent instance or
null
-
loadOptional
public Optional<T> loadOptional()
Description copied from interface:NaturalIdLoadAccess
Just likeNaturalIdLoadAccess.load()
, except that here anOptional
is returned.- Specified by:
loadOptional
in interfaceNaturalIdLoadAccess<T>
- Returns:
- The persistent instance, if one, as an
Optional
-
with
public NaturalIdLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic)
Description copied from interface:NaturalIdLoadAccess
Customize the associations fetched by specifying an entity graph, and how it should be interpreted.- Specified by:
with
in interfaceNaturalIdLoadAccess<T>
- Overrides:
with
in classBaseNaturalIdLoadAccessImpl<T>
-
enableFetchProfile
public NaturalIdLoadAccess<T> enableFetchProfile(String profileName)
Description copied from interface:NaturalIdLoadAccess
Customize 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:
enableFetchProfile
in interfaceNaturalIdLoadAccess<T>
- Overrides:
enableFetchProfile
in classBaseNaturalIdLoadAccessImpl<T>
-
disableFetchProfile
public NaturalIdLoadAccess<T> disableFetchProfile(String profileName)
Description copied from interface:NaturalIdLoadAccess
Customize 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:
disableFetchProfile
in interfaceNaturalIdLoadAccess<T>
- Overrides:
disableFetchProfile
in classBaseNaturalIdLoadAccessImpl<T>
-
-