Interface NaturalIdMultiLoadAccess<T>
- All Known Implementing Classes:
NaturalIdMultiLoadAccessStandard
List<Book> books = session.byMultipleNaturalId(Book.class) .withBatchSize(10) .multiLoad(isbnList);
Composite natural ids may be accommodated by passing a list of
maps of type Map<String,Object>
to multiLoad(java.lang.Object...)
.
Each map must contain the natural id attribute values keyed by
@NaturalId
attribute
name.
var compositeNaturalId = Map.of(Book_.ISBN, isbn, Book_.PRINTING, printing);
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionenableOrderedReturn
(boolean enabled) Should the returned list of entity instances be ordered, with the position of an entity instance determined by the position of its identifier in the list if ids passed tomultiLoad(java.lang.Object...)
?enableReturnOfDeletedEntities
(boolean enabled) ShouldmultiLoad(java.lang.Object...)
return entity instances that have beenmarked for removal
in the current session, but not yetdelete
d in the database?Retrieve the entities with the given natural id values.Retrieve the entities with the given natural id values.Specify theCacheMode
to use when obtaining an entity.default NaturalIdMultiLoadAccess<T>
Deprecated.with
(RootGraph<T> graph, GraphSemantic semantic) Customize the associations fetched by specifying an entity graph, and how it should be interpreted.with
(LockOptions lockOptions) Specify the lock options to use when querying the database.withBatchSize
(int batchSize) Specify a batch size, that is, how many entities should be fetched in each request to the database.default NaturalIdMultiLoadAccess<T>
withFetchGraph
(RootGraph<T> graph) Override the associations fetched by default by specifying the complete list of associations to be fetched as an entity graph.default NaturalIdMultiLoadAccess<T>
withLoadGraph
(RootGraph<T> graph) Augment the associations fetched by default by specifying a list of additional associations to be fetched as an entity graph.
-
Method Details
-
with
Specify the lock options to use when querying the database.- Parameters:
lockOptions
- The lock options to use- Returns:
this
, for method chaining
-
with
Specify theCacheMode
to use when obtaining an entity.- Parameters:
cacheMode
- TheCacheMode
to use- Returns:
this
, for method chaining
-
withFetchGraph
Override the associations fetched by default by specifying the complete list of associations to be fetched as an entity graph.- Since:
- 6.3
-
withLoadGraph
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
Customize the associations fetched by specifying an entity graph, and how it should be interpreted. -
withBatchSize
Specify a batch size, that is, how many entities should be fetched in each request to the database.- By default, the batch sizing strategy is determined by the SQL dialect, but
- if some
batchSize>1
is specified as an argument to this method, then that batch size will be used.
If an explicit batch size is set manually, care should be taken to not exceed the capabilities of the underlying database.
A batch size is considered a hint.
- Parameters:
batchSize
- The batch size- Returns:
this
, for method chaining
-
enableReturnOfDeletedEntities
ShouldmultiLoad(java.lang.Object...)
return entity instances that have beenmarked for removal
in the current session, but not yetdelete
d in the database?By default, instances marked for removal are replaced by null in the returned list of entities when
enableOrderedReturn(boolean)
is used.- Parameters:
enabled
-true
if removed entities should be returned;false
if they should be replaced by null values.- Returns:
this
, for method chaining
-
enableOrderedReturn
Should the returned list of entity instances be ordered, with the position of an entity instance determined by the position of its identifier in the list if ids passed tomultiLoad(java.lang.Object...)
?By default, the returned list is ordered and the positions of the entities correspond to the positions of their ids. In this case, the handling of entities marked for removal becomes important.
- Parameters:
enabled
-true
if entity instances should be ordered;false
if they may be returned in any order.- Returns:
this
, for method chaining
-
multiLoad
Retrieve the entities with the given natural id values.Note that the options
enableReturnOfDeletedEntities(boolean)
andenableOrderedReturn(boolean)
affect the size and shape of the returned list of entity instances.- Parameters:
ids
- The natural id values to load- Returns:
- The managed entities.
-
multiLoad
Retrieve the entities with the given natural id values.Note that the options
enableReturnOfDeletedEntities(boolean)
andenableOrderedReturn(boolean)
affect the size and shape of the returned list of entity instances.- Parameters:
ids
- The natural id values to load- Returns:
- The managed entities.
-
withLoadGraph(org.hibernate.graph.RootGraph<T>)