Package org.hibernate.loader.access
Class NaturalIdLoadAccessImpl<T>
- java.lang.Object
-
- org.hibernate.loader.access.BaseNaturalIdLoadAccessImpl<T>
-
- org.hibernate.loader.access.NaturalIdLoadAccessImpl<T>
-
- All Implemented Interfaces:
NaturalIdLoadOptions
,NaturalIdLoadAccess<T>
public class NaturalIdLoadAccessImpl<T> extends BaseNaturalIdLoadAccessImpl<T> implements NaturalIdLoadAccess<T>
-
-
Field Summary
-
Fields inherited from interface org.hibernate.loader.ast.spi.NaturalIdLoadOptions
NONE
-
-
Constructor Summary
Constructors Constructor Description NaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description T
getReference()
Return the persistent instance with the natural id value(s) defined by the call(s) toNaturalIdLoadAccess.using(java.lang.String, java.lang.Object)
.T
load()
Return the persistent instance with the natural id value(s) defined by the call(s) toNaturalIdLoadAccess.using(java.lang.String, java.lang.Object)
, ornull
if there is no such persistent instance.Optional<T>
loadOptional()
Same semantic asNaturalIdLoadAccess.load()
except that hereOptional
is returned to handle nullability.NaturalIdLoadAccessImpl<T>
setSynchronizationEnabled(boolean synchronizationEnabled)
For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness).NaturalIdLoadAccess<T>
using(Object... mappings)
Set multiple natural-id attribute values at once.NaturalIdLoadAccess<T>
using(String attributeName, Object value)
Add a NaturalId attribute value.NaturalIdLoadAccessImpl<T>
with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.-
Methods inherited from class org.hibernate.loader.access.BaseNaturalIdLoadAccessImpl
doGetReference, doLoad, entityPersister, getContext, getEntityDescriptor, getIdentifierLoadAccess, getLockOptions, isSynchronizationEnabled, performAnyNeededCrossReferenceSynchronizations, resolveNaturalId, synchronizationEnabled
-
-
-
-
Constructor Detail
-
NaturalIdLoadAccessImpl
public NaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor)
-
-
Method Detail
-
with
public NaturalIdLoadAccessImpl<T> with(LockOptions lockOptions)
Description copied from interface:NaturalIdLoadAccess
Specify theLockOptions
to use when retrieving the entity.- Specified by:
with
in interfaceNaturalIdLoadAccess<T>
- Overrides:
with
in classBaseNaturalIdLoadAccessImpl<T>
- Parameters:
lockOptions
- The lock options to use.- Returns:
this
, for method chaining
-
using
public NaturalIdLoadAccess<T> using(String attributeName, Object value)
Description copied from interface:NaturalIdLoadAccess
Add a NaturalId attribute value.- Specified by:
using
in interfaceNaturalIdLoadAccess<T>
- Parameters:
attributeName
- The entity attribute name that is marked as a NaturalIdvalue
- The value of the attribute- Returns:
this
, for method chaining
-
using
public NaturalIdLoadAccess<T> using(Object... mappings)
Description copied from interface:NaturalIdLoadAccess
Set multiple natural-id attribute values at once. The passed array is expected to have an even number of elements, with the attribute name followed by its value. E.g. `using( "system", "matrix", "username", "neo" )`- Specified by:
using
in interfaceNaturalIdLoadAccess<T>
- Returns:
this
, for method chaining
-
setSynchronizationEnabled
public NaturalIdLoadAccessImpl<T> setSynchronizationEnabled(boolean synchronizationEnabled)
Description copied from interface:NaturalIdLoadAccess
For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness). "synchronization" here indicates updating the natural-id -> pk cross reference maintained as part of the session. When enabled, prior to performing the lookup, Hibernate will check all entities of the given type associated with the session to see if its natural-id values have changed and, if so, update the cross reference. There is a performance impact associated with this, so if application developers are certain the natural-ids in play have not changed, this setting can be disabled to circumvent that impact. However, disabling this setting when natural-ids values have changed can result in incorrect results!- Specified by:
setSynchronizationEnabled
in interfaceNaturalIdLoadAccess<T>
- Parameters:
synchronizationEnabled
- Should synchronization be performed?true
indicates synchronization will be performed;false
indicates it will be circumvented.- Returns:
this
, for method chaining
-
getReference
public final T getReference()
Description copied from interface:NaturalIdLoadAccess
Return the persistent instance with the natural id value(s) defined by the call(s) toNaturalIdLoadAccess.using(java.lang.String, java.lang.Object)
. 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, useNaturalIdLoadAccess.load()
instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
getReference
in interfaceNaturalIdLoadAccess<T>
- Returns:
- the persistent instance or proxy
-
load
public final T load()
Description copied from interface:NaturalIdLoadAccess
Return the persistent instance with the natural id value(s) defined by the call(s) toNaturalIdLoadAccess.using(java.lang.String, java.lang.Object)
, ornull
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.- Specified by:
load
in interfaceNaturalIdLoadAccess<T>
- Returns:
- The persistent instance or
null
-
loadOptional
public Optional<T> loadOptional()
Description copied from interface:NaturalIdLoadAccess
Same semantic asNaturalIdLoadAccess.load()
except that hereOptional
is returned to handle nullability.- Specified by:
loadOptional
in interfaceNaturalIdLoadAccess<T>
- Returns:
- The persistent instance, if one, wrapped in Optional
-
-