类 PersistenceUtilHelper


  • public final class PersistenceUtilHelper
    extends Object
    Central delegate for handling calls from:
    • PersistenceUtil.isLoaded(Object)
    • PersistenceUtil.isLoaded(Object, String)
    • ProviderUtil.isLoaded(Object)
    • ProviderUtil.isLoadedWithReference(Object, String)
    • ProviderUtil.isLoadedWithoutReference(Object, String)li>
    作者:
    Emmanuel Bernard, Hardy Ferentschik, Steve Ebersole
    • 方法详细资料

      • isLoaded

        public static javax.persistence.spi.LoadState isLoaded​(Object reference)
        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:

        1. If the reference is a HibernateProxy, we return LoadState.LOADED if LazyInitializer.isUninitialized() returns false; else we return LoadState.NOT_LOADED
        2. If the reference is an enhanced (by Hibernate) entity, we return LoadState.LOADED if LazyAttributeLoadingInterceptor.hasAnyUninitializedAttributes() returns false; otherwise we return LoadState.NOT_LOADED
        3. If the reference is a PersistentCollection, we return LoadState.LOADED if PersistentCollection.wasInitialized() returns true; else we return LoadState.NOT_LOADED
        4. In all other cases we return LoadState.UNKNOWN
        参数:
        reference - The object reference to check.
        返回:
        The appropriate LoadState (see above)
      • isLoadedWithoutReference

        public static javax.persistence.spi.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).
        参数:
        entity - The entity
        attributeName - The name of the attribute to check
        cache - The cache we maintain of attribute resolutions
        返回:
        The LoadState
      • isLoadedWithReference

        public static javax.persistence.spi.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).
        参数:
        entity - The entity
        attributeName - The name of the attribute to check
        cache - The cache we maintain of attribute resolutions
        返回:
        The LoadState