程序包 org.hibernate
接口 NaturalIdLoadAccess<T>
-
public interface NaturalIdLoadAccess<T>Loads an entity by its natural identifier.- 作者:
- Eric Dalquist, Steve Ebersole
- 另请参阅:
NaturalId
-
-
方法概要
所有方法 实例方法 抽象方法 修饰符和类型 方法 说明 TgetReference()Return the persistent instance with the natural id value(s) defined by the call(s) tousing(java.lang.String, java.lang.Object).Tload()Return the persistent instance with the natural id value(s) defined by the call(s) tousing(java.lang.String, java.lang.Object), ornullif there is no such persistent instance.Optional<T>loadOptional()NaturalIdLoadAccess<T>setSynchronizationEnabled(boolean enabled)For entities with mutable natural ids, should Hibernate perform "synchronization" prior to performing lookups?NaturalIdLoadAccess<T>using(String attributeName, Object value)Add a NaturalId attribute value.NaturalIdLoadAccess<T>with(LockOptions lockOptions)Specify theLockOptionsto use when retrieving the entity.
-
-
-
方法详细资料
-
with
NaturalIdLoadAccess<T> with(LockOptions lockOptions)
Specify theLockOptionsto use when retrieving the entity.- 参数:
lockOptions- The lock options to use.- 返回:
this, for method chaining
-
using
NaturalIdLoadAccess<T> using(String attributeName, Object value)
Add a NaturalId attribute value.- 参数:
attributeName- The entity attribute name that is marked as a NaturalIdvalue- The value of the attribute- 返回:
this, for method chaining
-
setSynchronizationEnabled
NaturalIdLoadAccess<T> setSynchronizationEnabled(boolean enabled)
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!- 参数:
enabled- Should synchronization be performed?trueindicates synchronization will be performed;falseindicates it will be circumvented.- 返回:
this, for method chaining
-
getReference
T getReference()
Return the persistent instance with the natural id value(s) defined by the call(s) tousing(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, useload()instead. Use this only to retrieve an instance that you assume exists, where non-existence would be an actual error.- 返回:
- the persistent instance or proxy
-
load
T load()
Return the persistent instance with the natural id value(s) defined by the call(s) tousing(java.lang.String, java.lang.Object), 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.- 返回:
- The persistent instance or
null
-
-