Top Fields Constructors Methods
org.hibernate.loader.internal

public Class NaturalIdLoadAccessImpl<T>

extends BaseNaturalIdLoadAccessImpl<T>
implements NaturalIdLoadAccess<T>
Class Inheritance
All Implemented Interfaces
org.hibernate.NaturalIdLoadAccess
Imports
java.util.LinkedHashMap, .Map, .Optional, jakarta.persistence.metamodel.SingularAttribute, org.hibernate.LockOptions, .NaturalIdLoadAccess, org.hibernate.graph.GraphSemantic, .RootGraph, org.hibernate.internal.util.collections.CollectionHelper, org.hibernate.metamodel.mapping.EntityMappingType

Author
Steve Ebersole

Field Summary

Modifier and TypeField and Description
private final Map<String, Object>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public NaturalIdLoadAccess<T>
disableFetchProfile(String profileName)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.disableFetchProfile.

Implements org.hibernate.NaturalIdLoadAccess.disableFetchProfile.

Customize the associations fetched by specifying a fetch profile that should be disabled during this operation.
public NaturalIdLoadAccess<T>
enableFetchProfile(String profileName)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.enableFetchProfile.

Implements org.hibernate.NaturalIdLoadAccess.enableFetchProfile.

Customize the associations fetched by specifying a fetch profile that should be enabled during this operation.
public final T
getReference()

Implements org.hibernate.NaturalIdLoadAccess.getReference.

Return the persistent instance with the full natural id specified by previous calls to using.
public final T
load()

Implements org.hibernate.NaturalIdLoadAccess.load.

Return the persistent instance with the full natural id specified by previous calls to using, or null if there is no such persistent instance.
public Optional<T>
loadOptional()

Implements org.hibernate.NaturalIdLoadAccess.loadOptional.

Just like load, except that here an Optional is returned.
public NaturalIdLoadAccessImpl<T>
setSynchronizationEnabled(boolean
Should synchronization be performed? true indicates synchronization will be performed; false indicates it will be circumvented.
synchronizationEnabled
)

Implements org.hibernate.NaturalIdLoadAccess.setSynchronizationEnabled.

Determines if cached natural id cross-references are synchronized before query execution with unflushed modifications made in memory to mutable natural ids.
public <X> NaturalIdLoadAccess<T>
using(SingularAttribute<? super T, X>
A typesafe reference to an attribute of the entity that is annotated @NaturalId
attribute
,
X
The value of the attribute
value
)

Implements org.hibernate.NaturalIdLoadAccess.using.

Add a @NaturalId attribute value in a typesafe way.
public NaturalIdLoadAccess<T>
using(String
The name of an attribute of the entity that is annotated @NaturalId
attributeName
,
Object
The value of the attribute
value
)

Implements org.hibernate.NaturalIdLoadAccess.using.

Add a @NaturalId attribute value.
public NaturalIdLoadAccess<T>
using(Map<String, ?> mappings)

Implements org.hibernate.NaturalIdLoadAccess.using.

Set multiple @NaturalId attribute values at once.
public NaturalIdLoadAccess<T>
using(Object... mappings)

Implements org.hibernate.NaturalIdLoadAccess.using.

Deprecated
Set multiple @NaturalId attribute values at once.
public NaturalIdLoadAccessImpl<T>
with(LockOptions
The lock options to use.
lockOptions
)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.with.

Implements org.hibernate.NaturalIdLoadAccess.with.

Specify the lock options to use when querying the database.
public NaturalIdLoadAccess<T>
with(RootGraph<T> graph, GraphSemantic semantic)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.with.

Implements org.hibernate.NaturalIdLoadAccess.with.

Customize the associations fetched by specifying an entity graph, and how it should be interpreted.
Inherited from org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl:
doGetReferencedoLoadentityPersistergetContextgetEntityDescriptorgetIdentifierLoadAccessgetLockOptionsisSynchronizationEnabledperformAnyNeededCrossReferenceSynchronizationssynchronizationEnabled

Field Detail

naturalIdParametersback to summary
private final Map<String, Object> naturalIdParameters

Constructor Detail

NaturalIdLoadAccessImplback to summary
public NaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor)

Method Detail

disableFetchProfileback to summary
public NaturalIdLoadAccess<T> disableFetchProfile(String profileName)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.disableFetchProfile.

Implements org.hibernate.NaturalIdLoadAccess.disableFetchProfile.

Doc from org.hibernate.NaturalIdLoadAccess.disableFetchProfile.

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.

Annotations
@Override
enableFetchProfileback to summary
public NaturalIdLoadAccess<T> enableFetchProfile(String profileName)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.enableFetchProfile.

Implements org.hibernate.NaturalIdLoadAccess.enableFetchProfile.

Doc from org.hibernate.NaturalIdLoadAccess.enableFetchProfile.

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.

Annotations
@Override
getReferenceback to summary
public final T getReference()

Implements org.hibernate.NaturalIdLoadAccess.getReference.

Doc from org.hibernate.NaturalIdLoadAccess.getReference.

Return the persistent instance with the full natural id specified by previous calls to using. 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 load instead. Use this method only to retrieve an instance that you assume exists, where non-existence would be an actual error.

Returns:T

the persistent instance or proxy

Annotations
@Override
loadback to summary
public final T load()

Implements org.hibernate.NaturalIdLoadAccess.load.

Doc from org.hibernate.NaturalIdLoadAccess.load.

Return the persistent instance with the full natural id specified by previous calls to using, or null 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.

Returns:T

The persistent instance or null

Annotations
@Override
loadOptionalback to summary
public Optional<T> loadOptional()

Implements org.hibernate.NaturalIdLoadAccess.loadOptional.

Doc from org.hibernate.NaturalIdLoadAccess.loadOptional.

Just like load, except that here an Optional is returned.

Returns:Optional<T>

The persistent instance, if one, as an Optional

Annotations
@Override
setSynchronizationEnabledback to summary
public NaturalIdLoadAccessImpl<T> setSynchronizationEnabled(boolean synchronizationEnabled)

Implements org.hibernate.NaturalIdLoadAccess.setSynchronizationEnabled.

Doc from org.hibernate.NaturalIdLoadAccess.setSynchronizationEnabled.

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.

Parameters
synchronizationEnabled:boolean

Should synchronization be performed? true indicates synchronization will be performed; false indicates it will be circumvented.

Returns:NaturalIdLoadAccessImpl<T>

this, for method chaining

Annotations
@Override
usingback to summary
public <X> NaturalIdLoadAccess<T> using(SingularAttribute<? super T, X> attribute, X value)

Implements org.hibernate.NaturalIdLoadAccess.using.

Doc from org.hibernate.NaturalIdLoadAccess.using.

Add a @NaturalId attribute value in a typesafe way.

Parameters
attribute:SingularAttribute<? super T, X>

A typesafe reference to an attribute of the entity that is annotated @NaturalId

value:X

The value of the attribute

Returns:NaturalIdLoadAccess<T>

this, for method chaining

Annotations
@Override
usingback to summary
public NaturalIdLoadAccess<T> using(String attributeName, Object value)

Implements org.hibernate.NaturalIdLoadAccess.using.

Doc from org.hibernate.NaturalIdLoadAccess.using.

Add a @NaturalId attribute value.

Parameters
attributeName:String

The name of an attribute of the entity that is annotated @NaturalId

value:Object

The value of the attribute

Returns:NaturalIdLoadAccess<T>

this, for method chaining

Annotations
@Override
usingback to summary
public NaturalIdLoadAccess<T> using(Map<String, ?> mappings)

Implements org.hibernate.NaturalIdLoadAccess.using.

Doc from org.hibernate.NaturalIdLoadAccess.using.

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();
Returns:NaturalIdLoadAccess<T>

this, for method chaining

Annotations
@Override
usingback to summary
public NaturalIdLoadAccess<T> using(Object... mappings)

Implements org.hibernate.NaturalIdLoadAccess.using.

Doc from org.hibernate.NaturalIdLoadAccess.using.

Deprecated

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();
Returns:NaturalIdLoadAccess<T>

this, for method chaining

Annotations
@Override
@Deprecated
withback to summary
public NaturalIdLoadAccessImpl<T> with(LockOptions lockOptions)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.with.

Implements org.hibernate.NaturalIdLoadAccess.with.

Doc from org.hibernate.NaturalIdLoadAccess.with.

Specify the lock options to use when querying the database.

Parameters
lockOptions:LockOptions

The lock options to use.

Returns:NaturalIdLoadAccessImpl<T>

this, for method chaining

Annotations
@Override
withback to summary
public NaturalIdLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic)

Overrides org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl.with.

Implements org.hibernate.NaturalIdLoadAccess.with.

Doc from org.hibernate.NaturalIdLoadAccess.with.

Customize the associations fetched by specifying an entity graph, and how it should be interpreted.

Annotations
@Override