Package persist.hibernate.enhance.legacy
Class LegacyHibernateEnhancer
java.lang.Object
persist.hibernate.enhance.legacy.LegacyHibernateEnhancer
- All Implemented Interfaces:
HibernateEnhancer
HibernateEnhancer implementation for the legacy
javax.persistence namespace ("javax").
Uses the Hibernate 5 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface persist.hibernate.enhance.spi.HibernateEnhancer
HibernateEnhancer.Option -
Method Summary
Modifier and TypeMethodDescriptionbyte[]Enhances the bytecode of the given entity class.static LegacyHibernateEnhancerCreates a newLegacyHibernateEnhancerby building aURLClassLoaderfrom the given classes directory and classpath files.static LegacyHibernateEnhancerfrom(ClassLoader classLoader, Map<HibernateEnhancer.Option, Boolean> options) Creates a newLegacyHibernateEnhancerusing the supplied class loader and enhancement options.
-
Method Details
-
from
public static LegacyHibernateEnhancer from(ClassLoader classLoader, Map<HibernateEnhancer.Option, Boolean> options) Creates a newLegacyHibernateEnhancerusing the supplied class loader and enhancement options.- Parameters:
classLoader- the class loader used to resolve entity classesoptions- enhancement option flags- Returns:
- a new enhancer instance
-
from
public static LegacyHibernateEnhancer from(File classesDir, Set<File> classpathFiles, Map<HibernateEnhancer.Option, Boolean> options) Creates a newLegacyHibernateEnhancerby building aURLClassLoaderfrom the given classes directory and classpath files.- Parameters:
classesDir- the directory containing compiled entity class filesclasspathFiles- additional classpath entries (JARs or directories)options- enhancement option flags- Returns:
- a new enhancer instance
-
enhance
Enhances the bytecode of the given entity class.- Specified by:
enhancein interfaceHibernateEnhancer- 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
-