public interface IdentifierLoadAccess<T>
Loads an entity by its primary identifier.
Modifier and Type | Method and Description |
---|---|
T |
getReference(Serializable id)
Return the persistent instance with the given identifier, assuming that the instance exists.
|
T |
load(Serializable id)
Return the persistent instance with the given identifier, or null if there is no such persistent instance.
|
Optional<T> |
loadOptional(Serializable id)
Same semantic as
load(java.io.Serializable) except that here Optional is returned to
handle nullability. |
IdentifierLoadAccess<T> |
with(CacheMode cacheMode)
Specify the
CacheMode to use when retrieving the entity. |
IdentifierLoadAccess<T> |
with(LockOptions lockOptions)
Specify the
LockOptions to use when retrieving the entity. |
IdentifierLoadAccess<T> with(LockOptions lockOptions)
Specify the LockOptions
to use when retrieving the entity.
lockOptions
- The lock options to use.this
, for method chainingIdentifierLoadAccess<T> with(CacheMode cacheMode)
Specify the CacheMode
to use when retrieving the entity.
cacheMode
- The CacheMode to use.this
, for method chainingT getReference(Serializable 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, use load(java.io.Serializable)
instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an
actual error.
id
- The identifier for which to obtain a referenceT load(Serializable 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.
id
- The identifiernull
Optional<T> loadOptional(Serializable id)
Same semantic as load(java.io.Serializable)
except that here Optional
is returned to
handle nullability.
id
- The identifierCopyright © 2001-2018 Red Hat, Inc. All Rights Reserved.