Package org.hibernate.loader.internal
Class SimpleNaturalIdLoadAccessImpl<T>
java.lang.Object
org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl<T>
org.hibernate.loader.internal.SimpleNaturalIdLoadAccessImpl<T>
- All Implemented Interfaces:
NaturalIdLoadOptions,SimpleNaturalIdLoadAccess<T>
public class SimpleNaturalIdLoadAccessImpl<T>
extends BaseNaturalIdLoadAccessImpl<T>
implements SimpleNaturalIdLoadAccess<T>
Implementation of
SimpleNaturalIdLoadAccess.- Implementation Note:
- We allow use of
SimpleNaturalIdLoadAccessfor composite natural ids with the assumption that we will be given a singular representation of the natural id (a map or array).
-
Field Summary
Fields inherited from interface org.hibernate.loader.ast.spi.NaturalIdLoadOptions
NONE -
Constructor Summary
ConstructorsConstructorDescriptionSimpleNaturalIdLoadAccessImpl(LoadAccessContext context, EntityMappingType entityDescriptor) -
Method Summary
Modifier and TypeMethodDescriptiondisableFetchProfile(String profileName) Customize the associations fetched by specifying a fetch profile that should be disabled during this operation.enableFetchProfile(String profileName) Customize the associations fetched by specifying a fetch profile that should be enabled during this operation.The locking options for the loaded entitygetReference(Object naturalIdValue) Return the persistent instance with the given natural id value, assuming that the instance exists.booleanWhether Hibernate should perform "synchronization" prior to performing look-ups?Return the persistent instance with the given natural id value, ornullif there is no such persistent instance.loadOptional(Object naturalIdValue) Just likeSimpleNaturalIdLoadAccess.load(java.lang.Object), except that here anOptionalis returned.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).with(EntityGraph<T> graph, GraphSemantic semantic) Customize the associations fetched by specifying an entity graph, and how it should be interpreted.Specify the timeout to use when querying the database.with(LockMode lockMode, PessimisticLockScope lockScope) Specify the lock mode to use when querying the database.final SimpleNaturalIdLoadAccessImpl<T> with(LockOptions lockOptions) Specify the lock options to use when querying the database.withLoadGraph(EntityGraph<T> graph) Augment the associations fetched by default by specifying a list of additional associations to be fetched as an entity graph.Methods inherited from class org.hibernate.loader.internal.BaseNaturalIdLoadAccessImpl
doGetReference, doLoad, entityPersister, getContext, getEntityDescriptor, identifierLoadAccess, synchronizationEnabledMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.hibernate.SimpleNaturalIdLoadAccess
with, withFetchGraph
-
Constructor Details
-
SimpleNaturalIdLoadAccessImpl
-
-
Method Details
-
getLockOptions
Description copied from interface:NaturalIdLoadOptionsThe locking options for the loaded entity- Specified by:
getLockOptionsin interfaceNaturalIdLoadOptions- Overrides:
getLockOptionsin classBaseNaturalIdLoadAccessImpl<T>
-
isSynchronizationEnabled
public boolean isSynchronizationEnabled()Description copied from interface:NaturalIdLoadOptionsWhether Hibernate should perform "synchronization" prior to performing look-ups?- Specified by:
isSynchronizationEnabledin interfaceNaturalIdLoadOptions- Overrides:
isSynchronizationEnabledin classBaseNaturalIdLoadAccessImpl<T>
-
with
Description copied from interface:SimpleNaturalIdLoadAccessSpecify the lock mode to use when querying the database.- Specified by:
within interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
lockMode- The lock mode to apply- Returns:
this, for method chaining
-
with
Description copied from interface:SimpleNaturalIdLoadAccessSpecify the timeout to use when querying the database.- Specified by:
within interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
timeout- The timeout to apply to the database operation- Returns:
this, for method chaining
-
with
Description copied from interface:SimpleNaturalIdLoadAccessSpecify the lock options to use when querying the database.- Specified by:
within interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>- Parameters:
lockOptions- The lock options to use- Returns:
this, for method chaining
-
setSynchronizationEnabled
Description copied from interface:SimpleNaturalIdLoadAccessFor entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups? The default is to perform "synchronization" (for correctness).See
NaturalIdLoadAccess.setSynchronizationEnabled(boolean)for detailed discussion.- Specified by:
setSynchronizationEnabledin interfaceSimpleNaturalIdLoadAccess<T>- Parameters:
synchronizationEnabled- Should synchronization be performed?trueindicates synchronization will be performed;falseindicates it will be circumvented.- Returns:
this, for method chaining
-
getReference
Description copied from interface:SimpleNaturalIdLoadAccessReturn the persistent instance with the given natural id value, 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
SimpleNaturalIdLoadAccess.load(java.lang.Object)instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- Specified by:
getReferencein interfaceSimpleNaturalIdLoadAccess<T>- Parameters:
naturalIdValue- The value of the natural id- Returns:
- The persistent instance or proxy, if an instance exists.
Otherwise,
null.
-
load
Description copied from interface:SimpleNaturalIdLoadAccessReturn the persistent instance with the given natural id value, ornullif 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:
loadin interfaceSimpleNaturalIdLoadAccess<T>- Parameters:
naturalIdValue- The value of the natural-id- Returns:
- The persistent instance or
null
-
loadOptional
Description copied from interface:SimpleNaturalIdLoadAccessJust likeSimpleNaturalIdLoadAccess.load(java.lang.Object), except that here anOptionalis returned.- Specified by:
loadOptionalin interfaceSimpleNaturalIdLoadAccess<T>- Parameters:
naturalIdValue- The identifier- Returns:
- The persistent instance, if any, as an
Optional
-
with
Description copied from interface:SimpleNaturalIdLoadAccessCustomize the associations fetched by specifying an entity graph, and how it should be interpreted.- Specified by:
within interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
within classBaseNaturalIdLoadAccessImpl<T>
-
withLoadGraph
Description copied from interface:SimpleNaturalIdLoadAccessAugment the associations fetched by default by specifying a list of additional associations to be fetched as an entity graph.- Specified by:
withLoadGraphin interfaceSimpleNaturalIdLoadAccess<T>
-
enableFetchProfile
Description copied from interface:SimpleNaturalIdLoadAccessCustomize 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.
- Specified by:
enableFetchProfilein interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
enableFetchProfilein classBaseNaturalIdLoadAccessImpl<T>
-
disableFetchProfile
Description copied from interface:SimpleNaturalIdLoadAccessCustomize 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.
- Specified by:
disableFetchProfilein interfaceSimpleNaturalIdLoadAccess<T>- Overrides:
disableFetchProfilein classBaseNaturalIdLoadAccessImpl<T>
-