Class JakartaHibernateEnhancer

java.lang.Object
persist.hibernate.enhance.jakarta.JakartaHibernateEnhancer
All Implemented Interfaces:
HibernateEnhancer

public class JakartaHibernateEnhancer extends Object implements HibernateEnhancer
HibernateEnhancer implementation for the Jakarta Persistence namespace ("jakarta").

Uses the Hibernate ORM 6 bytecode enhancement SPI to transform compiled entity classes. The enhancer is configured with a set of HibernateEnhancer.Option flags that control which transformations — lazy initialisation, dirty tracking, association management, or extended enhancement — are applied.

Instances are created through the from(ClassLoader, java.util.Map) or from(java.io.File, java.util.Set, java.util.Map) factory methods.

Since:
1.0.0
See Also:
  • Method Details

    • from

      public static JakartaHibernateEnhancer from(ClassLoader classLoader, Map<HibernateEnhancer.Option,Boolean> options)
      Creates a new JakartaHibernateEnhancer using the supplied class loader and enhancement options.
      Parameters:
      classLoader - the class loader used to resolve entity classes
      options - enhancement option flags
      Returns:
      a new enhancer instance
    • from

      public static JakartaHibernateEnhancer from(File classesDir, Set<File> classpathFiles, Map<HibernateEnhancer.Option,Boolean> options)
      Creates a new JakartaHibernateEnhancer by building a URLClassLoader from the given classes directory and classpath files.
      Parameters:
      classesDir - the directory containing compiled entity class files
      classpathFiles - additional classpath entries (JARs or directories)
      options - enhancement option flags
      Returns:
      a new enhancer instance
    • enhance

      public byte[] enhance(String className, byte[] classBytes)
      Enhances the bytecode of the given entity class.
      Specified by:
      enhance in interface HibernateEnhancer
      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