Interface EnhancementContext
- All Superinterfaces:
EnhancementOptions
- All Known Implementing Classes:
DefaultEnhancementContext,EnhancementContextWrapper
The context for performing an enhancement. Enhancement can happen in any number of ways:
- Build time, via Ant
- Build time, via Maven
- Build time, via Gradle
- Runtime, via agent
- Runtime, via JPA constructs
This interface isolates the code that actually does the enhancement from the underlying context in which the enhancement is being performed.
-
Method Summary
Modifier and TypeMethodDescriptiondefault BytecodeProviderAllows to force the use of a specific instance of BytecodeProvider to perform the enhancement.Obtain access to the ClassLoader that can be used to load Class references.default UnsupportedEnhancementStrategybooleanhasLazyLoadableAttributes(UnloadedClass classDescriptor) Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement.booleanisCompositeClass(UnloadedClass classDescriptor) Does the given class name represent an embeddable/component class?booleanisDiscoveredType(UnloadedClass classDescriptor) booleanisEntityClass(UnloadedClass classDescriptor) Does the given class descriptor represent an entity class?booleanisLazyLoadable(UnloadedField field) Determine if a field is lazy loadable.booleanisMappedCollection(UnloadedField field) booleanisMappedSuperclassClass(UnloadedClass classDescriptor) Does the given class name represent a MappedSuperclass class?booleanisPersistentField(UnloadedField ctField) Does the field represent persistent state? Persistent fields will be "enhanced".order(UnloadedField[] persistentFields) For fields which are persistent (according toisPersistentField(org.hibernate.bytecode.enhance.spi.UnloadedField)), determine the corresponding ordering maintained within the Hibernate metamodel.voidregisterDiscoveredType(UnloadedClass classDescriptor, Type.PersistenceType type) Methods inherited from interface org.hibernate.bytecode.enhance.spi.EnhancementOptions
doBiDirectionalAssociationManagement, doBiDirectionalAssociationManagement, doDirtyCheckingInline, doDirtyCheckingInline, doExtendedEnhancement, doExtendedEnhancement
-
Method Details
-
getLoadingClassLoader
ClassLoader getLoadingClassLoader()Obtain access to the ClassLoader that can be used to load Class references. In JPA SPI terms, this should be a "temporary class loader" as defined byPersistenceUnitInfo.getNewTempClassLoader()- Returns:
- The class loader that the enhancer can use.
-
isEntityClass
Does the given class descriptor represent an entity class?- Parameters:
classDescriptor- The descriptor of the class to check.- Returns:
trueif the class is an entity;falseotherwise.
-
isCompositeClass
Does the given class name represent an embeddable/component class?- Parameters:
classDescriptor- The descriptor of the class to check.- Returns:
trueif the class is an embeddable/component;falseotherwise.
-
isMappedSuperclassClass
Does the given class name represent a MappedSuperclass class?- Parameters:
classDescriptor- The descriptor of the class to check.- Returns:
trueif the class is a mapped super class;falseotherwise.
-
hasLazyLoadableAttributes
Deprecated, for removal: This API element is subject to removal in a future version.Will be removed without replacement. See HHH-15641Does the given class define any lazy loadable attributes?- Parameters:
classDescriptor- The class to check- Returns:
- true/false
-
isPersistentField
Does the field represent persistent state? Persistent fields will be "enhanced".may be better to perform basic checks in the caller (non-static, etc) and call out with just the Class name and field name...
- Parameters:
ctField- The field reference.- Returns:
trueif the field is ;falseotherwise.
-
order
For fields which are persistent (according toisPersistentField(org.hibernate.bytecode.enhance.spi.UnloadedField)), determine the corresponding ordering maintained within the Hibernate metamodel.- Parameters:
persistentFields- The persistent field references.- Returns:
- The ordered references.
-
isLazyLoadable
Determine if a field is lazy loadable.- Parameters:
field- The field to check- Returns:
trueif the field is lazy loadable;falseotherwise.
-
isMappedCollection
- Parameters:
field- the field to check- Returns:
trueif the field is mapped
-
isDiscoveredType
-
registerDiscoveredType
-
getUnsupportedEnhancementStrategy
- Returns:
- The expected behavior when encountering a class that cannot be enhanced, in particular when attribute names don't match field names.
- See Also:
-
getBytecodeProvider
Allows to force the use of a specific instance of BytecodeProvider to perform the enhancement.- Returns:
- When returning {code null} the default implementation will be used. Only return a different instance if you need to override the default implementation.
-