Package org.hibernate.loader.internal
Class IdentifierLoadAccessImpl<T>
- java.lang.Object
-
- org.hibernate.loader.internal.IdentifierLoadAccessImpl<T>
-
- All Implemented Interfaces:
IdentifierLoadAccess<T>
,JavaType.CoercionContext
public class IdentifierLoadAccessImpl<T> extends Object implements IdentifierLoadAccess<T>, JavaType.CoercionContext
Standard implementation of load-by-id
-
-
Constructor Summary
Constructors Constructor Description IdentifierLoadAccessImpl(LoadAccessContext context, EntityPersister entityPersister)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected T
doGetReference(Object id)
protected T
doLoad(Object id)
T
getReference(Object id)
Return the persistent instance with the given identifier, assuming that the instance exists.TypeConfiguration
getTypeConfiguration()
T
load(Object id)
Return the persistent instance with the given identifier, or null if there is no such persistent instance.Optional<T>
loadOptional(Object id)
Same semantic asIdentifierLoadAccess.load(java.lang.Object)
except that hereOptional
is returned to handle nullability.protected T
perform(Supplier<T> executor)
IdentifierLoadAccess<T>
with(CacheMode cacheMode)
Specify theCacheMode
to use when retrieving the entity.IdentifierLoadAccess<T>
with(RootGraph<T> graph, GraphSemantic semantic)
IdentifierLoadAccessImpl<T>
with(LockOptions lockOptions)
Specify theLockOptions
to use when retrieving the entity.IdentifierLoadAccess<T>
withReadOnly(boolean readOnly)
Specify whether the entity should be loaded in read-only mode.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.hibernate.IdentifierLoadAccess
with
-
-
-
-
Constructor Detail
-
IdentifierLoadAccessImpl
public IdentifierLoadAccessImpl(LoadAccessContext context, EntityPersister entityPersister)
-
-
Method Detail
-
with
public final IdentifierLoadAccessImpl<T> with(LockOptions lockOptions)
Description copied from interface:IdentifierLoadAccess
Specify theLockOptions
to use when retrieving the entity.- Specified by:
with
in interfaceIdentifierLoadAccess<T>
- Parameters:
lockOptions
- The lock options to use.- Returns:
this
, for method chaining
-
with
public IdentifierLoadAccess<T> with(CacheMode cacheMode)
Description copied from interface:IdentifierLoadAccess
Specify theCacheMode
to use when retrieving the entity.- Specified by:
with
in interfaceIdentifierLoadAccess<T>
- Parameters:
cacheMode
- The CacheMode to use.- Returns:
this
, for method chaining
-
withReadOnly
public IdentifierLoadAccess<T> withReadOnly(boolean readOnly)
Description copied from interface:IdentifierLoadAccess
Specify whether the entity should be loaded in read-only mode.- Specified by:
withReadOnly
in interfaceIdentifierLoadAccess<T>
- See Also:
Session.setDefaultReadOnly(boolean)
-
with
public IdentifierLoadAccess<T> with(RootGraph<T> graph, GraphSemantic semantic)
- Specified by:
with
in interfaceIdentifierLoadAccess<T>
-
getReference
public final T getReference(Object id)
Description copied from interface:IdentifierLoadAccess
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
IdentifierLoadAccess.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:
getReference
in interfaceIdentifierLoadAccess<T>
- Parameters:
id
- The identifier for which to obtain a reference- Returns:
- the persistent instance or proxy
-
load
public final T load(Object id)
Description copied from interface:IdentifierLoadAccess
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.- Specified by:
load
in interfaceIdentifierLoadAccess<T>
- Parameters:
id
- The identifier- Returns:
- The persistent instance or
null
-
loadOptional
public Optional<T> loadOptional(Object id)
Description copied from interface:IdentifierLoadAccess
Same semantic asIdentifierLoadAccess.load(java.lang.Object)
except that hereOptional
is returned to handle nullability.- Specified by:
loadOptional
in interfaceIdentifierLoadAccess<T>
- Parameters:
id
- The identifier- Returns:
- The persistent instance, if one, wrapped in Optional
-
getTypeConfiguration
public TypeConfiguration getTypeConfiguration()
- Specified by:
getTypeConfiguration
in interfaceJavaType.CoercionContext
-
-