Top Description Inners Constructors Methods
org.hibernate.jpa.internal.util

public final Class PersistenceUtilHelper

extends Object
Class Inheritance
Imports
java.io.ObjectStreamException, .Serializable, java.lang.reflect.Field, .InvocationTargetException, .Method, java.security.PrivilegedAction, java.util.ArrayList, .HashMap, .List, .Map, jakarta.persistence.spi.LoadState, org.hibernate.HibernateException, org.hibernate.bytecode.enhance.spi.interceptor.BytecodeLazyAttributeInterceptor, .LazyAttributeLoadingInterceptor, org.hibernate.collection.spi.LazyInitializable, .PersistentCollection, org.hibernate.engine.spi.PersistentAttributeInterceptable, org.hibernate.internal.util.ReflectHelper, org.hibernate.internal.util.securitymanager.SystemSecurityManager, org.hibernate.proxy.HibernateProxy, .LazyInitializer

Central delegate for handling calls from:
Authors
Emmanuel Bernard, Hardy Ferentschik, Steve Ebersole

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
public static class
public static class
public static class
public static class
PersistenceUtilHelper.MetadataCache

Cache hierarchy and member resolution, taking care to not leak references to Class instances.

private static class
public static class
private static class

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static BytecodeLazyAttributeInterceptor
extractInterceptor(PersistentAttributeInterceptable interceptable)

Deprecated as a consequence of BytecodeLazyAttributeInterceptor being deprecated.
private static Object
public static LoadState

Returns:

The appropriate LoadState (see above)
getLoadState
(Object
The object reference to check.
reference
)

Determine if the given object reference represents loaded state.

private static Method

Returns:

Returns the method with the specified name or null if it does not exist.
getMethod
(Class<?>
The class to check.
clazz
,
String
The attribute name.
attributeName
)

Returns the method with the specified name or null if it does not exist.

private static boolean
public static LoadState

Returns:

The LoadState
isLoadedWithoutReference
(Object
The entity
entity
,
String
The name of the attribute to check
attributeName
,
PersistenceUtilHelper.MetadataCache
The cache we maintain of attribute resolutions
cache
)

Is the given attribute (by name) loaded?

public static LoadState

Returns:

The LoadState
isLoadedWithReference
(Object
The entity
entity
,
String
The name of the attribute to check
attributeName
,
PersistenceUtilHelper.MetadataCache
The cache we maintain of attribute resolutions
cache
)

Is the given attribute (by name) loaded?

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

PersistenceUtilHelperback to summary
private PersistenceUtilHelper()

Method Detail

extractInterceptorback to summary
private static BytecodeLazyAttributeInterceptor extractInterceptor(PersistentAttributeInterceptable interceptable)

Deprecated

as a consequence of BytecodeLazyAttributeInterceptor being deprecated. See corresponding docs for further information.

getAttributeValueback to summary
private static Object getAttributeValue(Object entity, String attributeName, PersistenceUtilHelper.MetadataCache cache)
getLoadStateback to summary
public static LoadState getLoadState(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:Object

The object reference to check.

Returns:LoadState

The appropriate LoadState (see above)

getMethodback to summary
private static Method getMethod(Class<?> clazz, String attributeName)

Returns the method with the specified name or null if it does not exist.

Parameters
clazz:Class<?>

The class to check.

attributeName:String

The attribute name.

Returns:Method

Returns the method with the specified name or null if it does not exist.

isInitializedback to summary
private static boolean isInitialized(PersistentAttributeInterceptable interceptable)
isLoadedWithoutReferenceback to summary
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:Object

The entity

attributeName:String

The name of the attribute to check

cache:PersistenceUtilHelper.MetadataCache

The cache we maintain of attribute resolutions

Returns:LoadState

The LoadState

isLoadedWithReferenceback to summary
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:Object

The entity

attributeName:String

The name of the attribute to check

cache:PersistenceUtilHelper.MetadataCache

The cache we maintain of attribute resolutions

Returns:LoadState

The LoadState

org.hibernate.jpa.internal.util back to summary

public Interface PersistenceUtilHelper.AttributeAccess

Known Direct Implementers
org.hibernate.jpa.internal.util.PersistenceUtilHelper.FieldAttributeAccess, org.hibernate.jpa.internal.util.PersistenceUtilHelper.MethodAttributeAccess, org.hibernate.jpa.internal.util.PersistenceUtilHelper.NoSuchAttributeAccess

Method Summary

Modifier and TypeMethod and Description
public Object

Method Detail

extractValueback to summary
public Object extractValue(Object owner) throws AttributeExtractionException
org.hibernate.jpa.internal.util back to summary

public Class PersistenceUtilHelper.AttributeExtractionException

extends HibernateException
Class Inheritance

Constructor Summary

AccessConstructor and Description
public
public

Constructor Detail

AttributeExtractionExceptionback to summary
public AttributeExtractionException(String message)
AttributeExtractionExceptionback to summary
public AttributeExtractionException(String message, Throwable cause)
org.hibernate.jpa.internal.util back to summary

public Class PersistenceUtilHelper.ClassMetadataCache

extends Object
Class Inheritance
  • java.lang.Object
  • org.hibernate.jpa.internal.util.PersistenceUtilHelper.ClassMetadataCache

Field Summary

Modifier and TypeField and Description
private final Map<String, PersistenceUtilHelper.AttributeAccess>
private final List<Class<?>>
private final Class<?>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
private PersistenceUtilHelper.AttributeAccess
buildAttributeAccess(final String attributeName)

private static List<Class<?>>
public PersistenceUtilHelper.AttributeAccess
getAttributeAccess(String attributeName)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeAccessMapback to summary
private final Map<String, PersistenceUtilHelper.AttributeAccess> attributeAccessMap
classHierarchyback to summary
private final List<Class<?>> classHierarchy
specifiedClassback to summary
private final Class<?> specifiedClass

Constructor Detail

ClassMetadataCacheback to summary
public ClassMetadataCache(Class<?> clazz)

Method Detail

buildAttributeAccessback to summary
private PersistenceUtilHelper.AttributeAccess buildAttributeAccess(final String attributeName)
findClassHierarchyback to summary
private static List<Class<?>> findClassHierarchy(Class<?> clazz)
getAttributeAccessback to summary
public PersistenceUtilHelper.AttributeAccess getAttributeAccess(String attributeName)
org.hibernate.jpa.internal.util back to summary

public Class PersistenceUtilHelper.FieldAttributeAccess

extends Object
implements AttributeAccess
Class Inheritance
  • java.lang.Object
  • org.hibernate.jpa.internal.util.PersistenceUtilHelper.FieldAttributeAccess
All Implemented Interfaces
org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess

Field Summary

Modifier and TypeField and Description
private final Field
private final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

fieldback to summary
private final Field field
nameback to summary
private final String name

Constructor Detail

FieldAttributeAccessback to summary
public FieldAttributeAccess(Field field)

Method Detail

extractValueback to summary
public Object extractValue(Object owner)

Implements org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess.extractValue.

Annotations
@Override
org.hibernate.jpa.internal.util back to summary

public final Class PersistenceUtilHelper.MetadataCache

extends Object
implements Serializable
Class Inheritance
  • java.lang.Object
  • org.hibernate.jpa.internal.util.PersistenceUtilHelper.MetadataCache
All Implemented Interfaces
java.io.Serializable

Cache hierarchy and member resolution, taking care to not leak references to Class instances.

Field Summary

Modifier and TypeField and Description
private final ClassValue<PersistenceUtilHelper.ClassMetadataCache>

Constructor Summary

AccessConstructor and Description
public
private

Method Summary

Modifier and TypeMethod and Description
pack-priv PersistenceUtilHelper.ClassMetadataCache
getClassMetadata(final Class<?> clazz)

private Object
pack-priv Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

metadataCacheClassValueback to summary
private final ClassValue<PersistenceUtilHelper.ClassMetadataCache> metadataCacheClassValue

Constructor Detail

MetadataCacheback to summary
public MetadataCache()
MetadataCacheback to summary
private MetadataCache(ClassValue<PersistenceUtilHelper.ClassMetadataCache> metadataCacheClassValue)

Method Detail

getClassMetadataback to summary
pack-priv PersistenceUtilHelper.ClassMetadataCache getClassMetadata(final Class<?> clazz)
readResolveback to summary
private Object readResolve() throws ObjectStreamException
writeReplaceback to summary
pack-priv Object writeReplace() throws ObjectStreamException
org.hibernate.jpa.internal.util back to summary

private final Class PersistenceUtilHelper.MetadataClassValue

extends ClassValue<PersistenceUtilHelper.ClassMetadataCache>
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected PersistenceUtilHelper.ClassMetadataCache
computeValue(final Class<T>
the type whose class value must be computed
type
)

Implements abstract java.lang.ClassValue.computeValue.

Computes the given class's derived value for this ClassValue.
Inherited from java.lang.ClassValue:
getremove

Constructor Detail

MetadataClassValueback to summary
private MetadataClassValue()

Method Detail

computeValueback to summary
protected PersistenceUtilHelper.ClassMetadataCache computeValue(final Class<T> type)

Implements abstract java.lang.ClassValue.computeValue.

Doc from java.lang.ClassValue.computeValue.

Computes the given class's derived value for this ClassValue.

This method will be invoked within the first thread that accesses the value with the get method.

Normally, this method is invoked at most once per class, but it may be invoked again if there has been a call to remove.

If this method throws an exception, the corresponding call to get will terminate abnormally with that exception, and no class value will be recorded.

Parameters
type:Class<T>

the type whose class value must be computed

Returns:PersistenceUtilHelper.ClassMetadataCache

the newly computed value associated with this ClassValue, for the given class or interface

Annotations
@Override
org.hibernate.jpa.internal.util back to summary

public Class PersistenceUtilHelper.MethodAttributeAccess

extends Object
implements AttributeAccess
Class Inheritance
  • java.lang.Object
  • org.hibernate.jpa.internal.util.PersistenceUtilHelper.MethodAttributeAccess
All Implemented Interfaces
org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess

Field Summary

Modifier and TypeField and Description
private final Method
private final String

Constructor Summary

AccessConstructor and Description
public
MethodAttributeAccess(String attributeName, Method method)

Method Summary

Modifier and TypeMethod and Description
public Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

methodback to summary
private final Method method
nameback to summary
private final String name

Constructor Detail

MethodAttributeAccessback to summary
public MethodAttributeAccess(String attributeName, Method method)

Method Detail

extractValueback to summary
public Object extractValue(Object owner)

Implements org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess.extractValue.

Annotations
@Override
org.hibernate.jpa.internal.util back to summary

private Class PersistenceUtilHelper.NoSuchAttributeAccess

extends Object
implements AttributeAccess
Class Inheritance
  • java.lang.Object
  • org.hibernate.jpa.internal.util.PersistenceUtilHelper.NoSuchAttributeAccess
All Implemented Interfaces
org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess

Field Summary

Modifier and TypeField and Description
private final String
private final Class<?>

Constructor Summary

AccessConstructor and Description
public
NoSuchAttributeAccess(Class<?> clazz, String attributeName)

Method Summary

Modifier and TypeMethod and Description
public Object
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attributeNameback to summary
private final String attributeName
clazzback to summary
private final Class<?> clazz

Constructor Detail

NoSuchAttributeAccessback to summary
public NoSuchAttributeAccess(Class<?> clazz, String attributeName)

Method Detail

extractValueback to summary
public Object extractValue(Object owner) throws AttributeExtractionException

Implements org.hibernate.jpa.internal.util.PersistenceUtilHelper.AttributeAccess.extractValue.

Annotations
@Override