Package org.hibernate
Interface NaturalIdMultiLoadAccess<T>
-
- All Known Implementing Classes:
NaturalIdMultiLoadAccessStandard
public interface NaturalIdMultiLoadAccess<T>
Defines the ability to load multiple entities by simple natural-id simultaneously.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description static Map<String,?>
compoundValue(Object... elements)
Helper for creating a Map that represents the value of a compound natural-id for use in loading.NaturalIdMultiLoadAccess<T>
enableOrderedReturn(boolean enabled)
Should the return List be ordered and positional in relation to the incoming ids? If enabled (the default), the return List is ordered and positional relative to the incoming ids.NaturalIdMultiLoadAccess<T>
enableReturnOfDeletedEntities(boolean enabled)
Should the multi-load operation be allowed to return entities that are locally deleted? A locally deleted entity is one which has been passed to this Session'sSession.delete(java.lang.Object)
/Session.remove(java.lang.Object)
method, but not yet flushed.List<T>
multiLoad(Object... ids)
Perform a load of multiple entities by natural-id.List<T>
multiLoad(List<?> ids)
Perform a load of multiple entities by natural-id.NaturalIdMultiLoadAccess<T>
with(CacheMode cacheMode)
Specify theCacheMode
to use when retrieving the entity.default NaturalIdMultiLoadAccess<T>
with(RootGraph<T> graph)
Define a load graph to be used when retrieving the entityNaturalIdMultiLoadAccess<T>
with(RootGraph<T> graph, GraphSemantic semantic)
Define a load or fetch graph to be used when retrieving the entityNaturalIdMultiLoadAccess<T>
with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.NaturalIdMultiLoadAccess<T>
withBatchSize(int batchSize)
Specify a batch size for loading the entities (how many at a time).
-
-
-
Method Detail
-
with
NaturalIdMultiLoadAccess<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
NaturalIdMultiLoadAccess<T> with(CacheMode cacheMode)
Specify theCacheMode
to use when retrieving the entity.- Parameters:
cacheMode
- The CacheMode to use.- Returns:
this
, for method chaining
-
with
default NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph)
Define a load graph to be used when retrieving the entity
-
with
NaturalIdMultiLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic)
Define a load or fetch graph to be used when retrieving the entity
-
withBatchSize
NaturalIdMultiLoadAccess<T> withBatchSize(int batchSize)
Specify a batch size for loading the entities (how many at a time). The default is to use a batch sizing strategy defined by the Dialect in use. Any greater-than-one value here will override that default behavior. If giving an explicit value here, care should be taken to not exceed the capabilities of the underlying database.Note that overall a batch-size is considered a hint.
- Parameters:
batchSize
- The batch size- Returns:
this
, for method chaining
-
enableReturnOfDeletedEntities
NaturalIdMultiLoadAccess<T> enableReturnOfDeletedEntities(boolean enabled)
Should the multi-load operation be allowed to return entities that are locally deleted? A locally deleted entity is one which has been passed to this Session'sSession.delete(java.lang.Object)
/Session.remove(java.lang.Object)
method, but not yet flushed. The default behavior is to handle them as null in the return (seeenableOrderedReturn(boolean)
).- Parameters:
enabled
-true
enables returning the deleted entities;false
(the default) disables it.- Returns:
this
, for method chaining
-
enableOrderedReturn
NaturalIdMultiLoadAccess<T> enableOrderedReturn(boolean enabled)
Should the return List be ordered and positional in relation to the incoming ids? If enabled (the default), the return List is ordered and positional relative to the incoming ids. In other words, a request tomultiLoad([2,1,3])
will return[Entity#2, Entity#1, Entity#3]
.An important distinction is made here in regards to the handling of unknown entities depending on this "ordered return" setting. If enabled a null is inserted into the List at the proper position(s). If disabled, the nulls are not put into the return List. In other words, consumers of the returned ordered List would need to be able to handle null elements.
- Parameters:
enabled
-true
(the default) enables ordering;false
disables it.- Returns:
this
, for method chaining
-
multiLoad
List<T> multiLoad(Object... ids)
Perform a load of multiple entities by natural-id.See
enableOrderedReturn(boolean)
andenableReturnOfDeletedEntities(boolean)
for options which effect the size and "shape" of the return list.- Parameters:
ids
- The natural-id values to load- Returns:
- The managed entities.
-
multiLoad
List<T> multiLoad(List<?> ids)
Perform a load of multiple entities by natural-id.See
enableOrderedReturn(boolean)
andenableReturnOfDeletedEntities(boolean)
for options which effect the size and "shape" of the return list.- Parameters:
ids
- The natural-id values to load- Returns:
- The managed entities.
-
compoundValue
static Map<String,?> compoundValue(Object... elements)
Helper for creating a Map that represents the value of a compound natural-id for use in loading. The passed array is expected to have an even number of elements representing key, value pairs. E.g. `using( "system", "matrix", "username", "neo" )`
-
-