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 Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enhancement options that control which bytecode transformations are applied during entity enhancement.
  • Method Summary

    Modifier and Type
    Method
    Description
    createURLClassLoader(File classesDir, Set<File> classpathFiles, ClassLoader parent)
    Creates a URLClassLoader whose classpath consists of the compiled classes directory followed by the supplied classpath files.
    byte[]
    enhance(String className, byte[] classBytes)
    Enhances the bytecode of the given entity class.
    static URL
    toURL(File file)
    Converts a File to a URL.
  • Method Details

    • enhance

      byte[] enhance(String className, byte[] classBytes)
      Enhances the bytecode of the given entity class.
      Parameters:
      className - the fully qualified name of the class being enhanced
      classBytes - the original class bytes read from disk
      Returns:
      the enhanced class bytes, or the original bytes if no enhancement was applied
    • toURL

      static URL toURL(File file)
      Converts a File to a URL.
      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 a URLClassLoader whose classpath consists of the compiled classes directory followed by the supplied classpath files.
      Parameters:
      classesDir - the directory containing compiled class files
      classpathFiles - additional classpath entries (JARs or directories)
      parent - the parent class loader to delegate to
      Returns:
      a new class loader covering the specified classpath