Package org.hibernate.jpa.internal.util
Class PersistenceUtilHelper
java.lang.Object
org.hibernate.jpa.internal.util.PersistenceUtilHelper
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interface
static class
static class
static class
static final class
Cache hierarchy and member resolution, taking care to not leak references to Class instances.static class
-
Method Summary
Modifier and TypeMethodDescriptionstatic LoadState
getLoadState
(Object reference) Determine if the given object reference represents loaded state.static LoadState
isLoadedWithoutReference
(Object entity, String attributeName, PersistenceUtilHelper.MetadataCache cache) Is the given attribute (by name) loaded? This form must take care to not access the attribute (trigger initialization).static LoadState
isLoadedWithReference
(Object entity, String attributeName, PersistenceUtilHelper.MetadataCache cache) Is the given attribute (by name) loaded? This form must take care to not access the attribute (trigger initialization).
-
Method Details
-
getLoadState
Determine if the given object reference represents loaded state. The reference may be to an entity or a persistent collection.Return is defined as follows:
-
If the reference is a
HibernateProxy
, we returnLoadState.LOADED
ifLazyInitializer.isUninitialized()
returnsfalse
; else we returnLoadState.NOT_LOADED
-
If the reference is an enhanced (by Hibernate) entity, we return
LoadState.LOADED
ifLazyAttributeLoadingInterceptor.hasAnyUninitializedAttributes()
returnsfalse
; otherwise we returnLoadState.NOT_LOADED
-
If the reference is a
PersistentCollection
, we returnLoadState.LOADED
ifLazyInitializable.wasInitialized()
returnstrue
; else we returnLoadState.NOT_LOADED
-
In all other cases we return
LoadState.UNKNOWN
- Parameters:
reference
- The object reference to check.- Returns:
- The appropriate LoadState (see above)
-
If the reference is a
-
isLoadedWithoutReference
public static LoadState isLoadedWithoutReference(Object entity, String attributeName, PersistenceUtilHelper.MetadataCache cache) Is the given attribute (by name) loaded? This form must take care to not access the attribute (trigger initialization).- Parameters:
entity
- The entityattributeName
- The name of the attribute to checkcache
- The cache we maintain of attribute resolutions- Returns:
- The LoadState
-
isLoadedWithReference
public static LoadState isLoadedWithReference(Object entity, String attributeName, PersistenceUtilHelper.MetadataCache cache) Is the given attribute (by name) loaded? This form must take care to not access the attribute (trigger initialization).- Parameters:
entity
- The entityattributeName
- The name of the attribute to checkcache
- The cache we maintain of attribute resolutions- Returns:
- The LoadState
-