Class 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>
    • Method Detail

      • isLoaded

        public static jakarta.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
        Parameters:
        reference - The object reference to check.
        Returns:
        The appropriate LoadState (see above)
      • isLoadedWithoutReference

        public static jakarta.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).
        Parameters:
        entity - The entity
        attributeName - The name of the attribute to check
        cache - The cache we maintain of attribute resolutions
        Returns:
        The LoadState
      • isLoadedWithReference

        public static jakarta.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).
        Parameters:
        entity - The entity
        attributeName - The name of the attribute to check
        cache - The cache we maintain of attribute resolutions
        Returns:
        The LoadState