Package org.hibernate
Interface SimpleNaturalIdLoadAccess<T>
-
public interface SimpleNaturalIdLoadAccess<T>
Loads an entity by its natural identifier.- See Also:
NaturalId
,NaturalIdLoadAccess
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description T
getReference(java.lang.Object naturalIdValue)
Return the persistent instance with the given natural id value, assuming that the instance exists.T
load(java.lang.Object naturalIdValue)
Return the persistent instance with the given natural id value, ornull
if there is no such persistent instance.java.util.Optional<T>
loadOptional(java.io.Serializable naturalIdValue)
Same semantic asload(java.lang.Object)
except that hereOptional
is returned to handle nullability.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).SimpleNaturalIdLoadAccess<T>
with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.
-
-
-
Method Detail
-
with
SimpleNaturalIdLoadAccess<T> with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.- Parameters:
lockOptions
- The lock options to use.- Returns:
this
, for method chaining
-
setSynchronizationEnabled
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). SeeNaturalIdLoadAccess.setSynchronizationEnabled(boolean)
for detailed discussion.- Parameters:
enabled
- Should synchronization be performed?true
indicates synchronization will be performed;false
indicates it will be circumvented.- Returns:
this
, for method chaining
-
getReference
T getReference(java.lang.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, useload(java.lang.Object)
instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Parameters:
naturalIdValue
- The value of the natural-id for the entity to retrieve- Returns:
- The persistent instance or proxy, if an instance exists. Otherwise,
null
.
-
load
T load(java.lang.Object naturalIdValue)
Return the persistent instance with the given natural id value, 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.- Parameters:
naturalIdValue
- The value of the natural-id for the entity to retrieve- Returns:
- The persistent instance or
null
-
loadOptional
java.util.Optional<T> loadOptional(java.io.Serializable naturalIdValue)
Same semantic asload(java.lang.Object)
except that hereOptional
is returned to handle nullability.- Parameters:
naturalIdValue
- The identifier- Returns:
- The persistent instance, if one, wrapped in Optional
-
-