Package org.hibernate
Interface IdentifierLoadAccess<T>
Deprecated, for removal: This API element is subject to removal in a future version.
Use forms of Session.find(java.lang.Class<T>, java.lang.Object) accepting
FindOption instead of Session.byId(java.lang.Class<T>).
Loads an entity by its primary identifier.
The interface is especially useful when customizing association
fetching using an EntityGraph
.
var graph = session.createEntityGraph(Book.class); graph.addSubgraph(Book_.publisher); graph.addPluralSubgraph(Book_.authors) .addSubgraph(Author_.person); Book book = session.byId(Book.class) .withFetchGraph(graph) .load(bookId);
It's also useful for loading entity instances with a specific cache interaction mode in effect, or in read-only mode.
Book book = session.byId(Book.class) .with(CacheMode.GET) .withReadOnly(true) .load(bookId);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptiondisableFetchProfile
(String profileName) Deprecated, for removal: This API element is subject to removal in a future version.Customize the associations fetched by specifying a fetch profile that should be disabled during this operation.enableFetchProfile
(String profileName) Deprecated, for removal: This API element is subject to removal in a future version.Customize the associations fetched by specifying a fetch profile that should be enabled during this operation.getReference
(Object id) Deprecated, for removal: This API element is subject to removal in a future version.Return the persistent instance with the given identifier, assuming that the instance exists.Deprecated, for removal: This API element is subject to removal in a future version.Return the persistent instance with the given identifier, or null if there is no such persistent instance.loadOptional
(Object id) Deprecated, for removal: This API element is subject to removal in a future version.Just likeload(java.lang.Object)
, except that here anOptional
is returned.default IdentifierLoadAccess
<T> with
(EntityGraph<T> graph) Deprecated.with
(EntityGraph<T> graph, GraphSemantic semantic) Deprecated, for removal: This API element is subject to removal in a future version.Customize the associations fetched by specifying an entity graph, and how it should be interpreted.Deprecated, for removal: This API element is subject to removal in a future version.Specify the timeout to use when querying the database.Deprecated, for removal: This API element is subject to removal in a future version.Specify theCacheMode
to use when obtaining an entity.default IdentifierLoadAccess
<T> Deprecated, for removal: This API element is subject to removal in a future version.Specify the lock mode to use when querying the database.with
(LockMode lockMode, PessimisticLockScope lockScope) Deprecated, for removal: This API element is subject to removal in a future version.Specify the lock mode to use when querying the database.with
(LockOptions lockOptions) Deprecated, for removal: This API element is subject to removal in a future version.default IdentifierLoadAccess
<T> withFetchGraph
(EntityGraph<T> graph) Deprecated, for removal: This API element is subject to removal in a future version.Override the associations fetched by default by specifying the complete list of associations to be fetched as an entity graph.default IdentifierLoadAccess
<T> withLoadGraph
(EntityGraph<T> graph) Deprecated, for removal: This API element is subject to removal in a future version.Augment the associations fetched by default by specifying a list of additional associations to be fetched as an entity graph.withReadOnly
(boolean readOnly) Deprecated, for removal: This API element is subject to removal in a future version.Specify whether the entity should be loaded in read-only mode.
-
Method Details
-
with
Deprecated, for removal: This API element is subject to removal in a future version.Specify the lock mode to use when querying the database.- Parameters:
lockMode
- The lock mode to apply- Returns:
this
, for method chaining
-
with
Deprecated, for removal: This API element is subject to removal in a future version.Specify the lock mode to use when querying the database.- Parameters:
lockMode
- The lock mode to apply- Returns:
this
, for method chaining
-
with
Deprecated, for removal: This API element is subject to removal in a future version.Specify the timeout to use when querying the database.- Parameters:
timeout
- The timeout to apply to the database operation- Returns:
this
, for method chaining
-
with
Deprecated, for removal: This API element is subject to removal in a future version.Specify the lock options to use when querying the database.- Parameters:
lockOptions
- The lock options to use- Returns:
this
, for method chaining
-
with
Deprecated, for removal: This API element is subject to removal in a future version.Specify theCacheMode
to use when obtaining an entity.- Parameters:
cacheMode
- TheCacheMode
to use- Returns:
this
, for method chaining
-
withReadOnly
Deprecated, for removal: This API element is subject to removal in a future version.Specify whether the entity should be loaded in read-only mode.- See Also:
-
withFetchGraph
Deprecated, for removal: This API element is subject to removal in a future version.Override the associations fetched by default by specifying the complete list of associations to be fetched as an entity graph.- Since:
- 6.3
-
withLoadGraph
Deprecated, for removal: This API element is subject to removal in a future version.Augment the associations fetched by default by specifying a list of additional associations to be fetched as an entity graph.- Since:
- 6.3
-
with
Deprecated. -
with
Deprecated, for removal: This API element is subject to removal in a future version.Customize the associations fetched by specifying an entity graph, and how it should be interpreted. -
enableFetchProfile
Deprecated, for removal: This API element is subject to removal in a future version.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.
- Since:
- 6.3
-
disableFetchProfile
Deprecated, for removal: This API element is subject to removal in a future version.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.
- Since:
- 6.3
-
getReference
Deprecated, for removal: This API element is subject to removal in a future version.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.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
Deprecated, for removal: This API element is subject to removal in a future version.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
Deprecated, for removal: This API element is subject to removal in a future version.Just likeload(java.lang.Object)
, except that here anOptional
is returned.- Parameters:
id
- The identifier- Returns:
- The persistent instance, if any, as an
Optional
-