Top Description Methods
org.hibernate

public Interface SimpleNaturalIdLoadAccess<T>

Known Direct Implementers
org.hibernate.internal.SessionImpl.SimpleNaturalIdLoadAccessImpl
Imports
java.io.Serializable, java.util.Optional

Loads an entity by its natural identifier.
Authors
Eric Dalquist, Steve Ebersole
See Also
org.hibernate.annotations.NaturalId, NaturalIdLoadAccess

Method Summary

Modifier and TypeMethod and Description
public T

Returns:

The persistent instance or proxy, if an instance exists. Otherwise, null.
getReference
(Object
The value of the natural-id for the entity to retrieve
naturalIdValue
)

Return the persistent instance with the given natural id value, assuming that the instance exists.

public T

Returns:

The persistent instance or null
load
(Object
The value of the natural-id for the entity to retrieve
naturalIdValue
)

Return the persistent instance with the given natural id value, or null if there is no such persistent instance.

public Optional<T>

Returns:

The persistent instance, if one, wrapped in Optional
loadOptional
(Serializable
The identifier
naturalIdValue
)

Same semantic as load except that here Optional is returned to handle nullability.

public SimpleNaturalIdLoadAccess<T>

Returns:

this, for method chaining
setSynchronizationEnabled
(boolean
Should synchronization be performed? true indicates synchronization will be performed; false indicates it will be circumvented.
enabled
)

For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups?

public SimpleNaturalIdLoadAccess<T>

Returns:

this, for method chaining
with
(LockOptions
The lock options to use.
lockOptions
)

Specify the org.hibernate.LockOptions to use when retrieving the entity.

Method Detail

getReferenceback to summary
public T getReference(Object naturalIdValue)

Return the persistent instance with the given natural id value, assuming that the instance exists. 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 only to retrieve an instance that you assume exists, where non-existence would be an actual error.

Parameters
naturalIdValue:Object

The value of the natural-id for the entity to retrieve

Returns:T

The persistent instance or proxy, if an instance exists. Otherwise, null.

loadback to summary
public T load(Object naturalIdValue)

Return the persistent instance with the given natural id value, 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.

Parameters
naturalIdValue:Object

The value of the natural-id for the entity to retrieve

Returns:T

The persistent instance or null

loadOptionalback to summary
public Optional<T> loadOptional(Serializable naturalIdValue)

Same semantic as load except that here Optional is returned to handle nullability.

Parameters
naturalIdValue:Serializable

The identifier

Returns:Optional<T>

The persistent instance, if one, wrapped in Optional

setSynchronizationEnabledback to summary
public SimpleNaturalIdLoadAccess<T> setSynchronizationEnabled(boolean enabled)

For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness).

See NaturalIdLoadAccess#setSynchronizationEnabled for detailed discussion.

Parameters
enabled:boolean

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

Returns:SimpleNaturalIdLoadAccess<T>

this, for method chaining

withback to summary
public SimpleNaturalIdLoadAccess<T> with(LockOptions lockOptions)

Specify the org.hibernate.LockOptions to use when retrieving the entity.

Parameters
lockOptions:LockOptions

The lock options to use.

Returns:SimpleNaturalIdLoadAccess<T>

this, for method chaining