Package org.hibernate
Interface IdentifierLoadAccess<T>
-
- All Known Implementing Classes:
IdentifierLoadAccessImpl
public interface IdentifierLoadAccess<T>
Loads an entity by its primary identifier.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description T
getReference(Object id)
Return the persistent instance with the given identifier, assuming that the instance exists.T
load(Object id)
Return the persistent instance with the given identifier, or null if there is no such persistent instance.Optional<T>
loadOptional(Object id)
Same semantic asload(java.lang.Object)
except that hereOptional
is returned to handle nullability.IdentifierLoadAccess<T>
with(CacheMode cacheMode)
Specify theCacheMode
to use when retrieving the entity.default IdentifierLoadAccess<T>
with(RootGraph<T> graph)
IdentifierLoadAccess<T>
with(RootGraph<T> graph, GraphSemantic semantic)
IdentifierLoadAccess<T>
with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.IdentifierLoadAccess<T>
withReadOnly(boolean readOnly)
Specify whether the entity should be loaded in read-only mode.
-
-
-
Method Detail
-
with
IdentifierLoadAccess<T> with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.- Parameters:
lockOptions
- The lock options to use.- Returns:
this
, for method chaining
-
with
IdentifierLoadAccess<T> with(CacheMode cacheMode)
Specify theCacheMode
to use when retrieving the entity.- Parameters:
cacheMode
- The CacheMode to use.- Returns:
this
, for method chaining
-
withReadOnly
IdentifierLoadAccess<T> withReadOnly(boolean readOnly)
Specify whether the entity should be loaded in read-only mode.- See Also:
Session.setDefaultReadOnly(boolean)
-
with
default IdentifierLoadAccess<T> with(RootGraph<T> graph)
-
with
IdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic)
-
getReference
T getReference(Object id)
Return the persistent instance with the given identifier, 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:
id
- The identifier for which to obtain a reference- Returns:
- the persistent instance or proxy
-
load
T load(Object id)
Return the persistent instance with the given identifier, 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:
id
- The identifier- Returns:
- The persistent instance or
null
-
loadOptional
Optional<T> loadOptional(Object id)
Same semantic asload(java.lang.Object)
except that hereOptional
is returned to handle nullability.- Parameters:
id
- The identifier- Returns:
- The persistent instance, if one, wrapped in Optional
-
-