Package persist.hibernate.enhance.spi
Interface HibernateEnhancer
- All Known Implementing Classes:
JakartaHibernateEnhancer,LegacyHibernateEnhancer
public interface HibernateEnhancer
SPI for Hibernate bytecode enhancement of JPA entity classes.
Implementations transform compiled entity class bytes to add Hibernate-specific instrumentation such as lazy-loading proxies, inline dirty tracking, bi-directional association management, and extended enhancement. The transformation is performed entirely at build time so that enhanced classes are ready for deployment without runtime bytecode manipulation.
Concrete implementations are namespace-specific: Jakarta
Persistence classes are enhanced by
JakartaHibernateEnhancer (Hibernate 6), while legacy
javax.persistence classes are handled by
LegacyHibernateEnhancer (Hibernate 5). Instances are
typically obtained through a HibernateEnhancerProvider.
- Since:
- 1.0.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumEnhancement options that control which bytecode transformations are applied during entity enhancement. -
Method Summary
Modifier and TypeMethodDescriptionstatic URLClassLoadercreateURLClassLoader(File classesDir, Set<File> classpathFiles, ClassLoader parent) Creates aURLClassLoaderwhose classpath consists of the compiled classes directory followed by the supplied classpath files.byte[]Enhances the bytecode of the given entity class.static URL
-
Method Details
-
enhance
Enhances the bytecode of the given entity class.- Parameters:
className- the fully qualified name of the class being enhancedclassBytes- the original class bytes read from disk- Returns:
- the enhanced class bytes, or the original bytes if no enhancement was applied
-
toURL
- Parameters:
file- the file to convert- Returns:
- the corresponding URL
- Throws:
RuntimeException- if the file URI cannot be converted to a URL
-
createURLClassLoader
static URLClassLoader createURLClassLoader(File classesDir, Set<File> classpathFiles, ClassLoader parent) Creates aURLClassLoaderwhose classpath consists of the compiled classes directory followed by the supplied classpath files.- Parameters:
classesDir- the directory containing compiled class filesclasspathFiles- additional classpath entries (JARs or directories)parent- the parent class loader to delegate to- Returns:
- a new class loader covering the specified classpath
-