Class DefaultEnhancementModel

java.lang.Object
org.hibernate.bytecode.enhance.spi.DefaultEnhancementModel
All Implemented Interfaces:
EnhancementModel

public class DefaultEnhancementModel extends Object implements EnhancementModel

Annotation-based persistence interpretation using Hibernate's enhancement defaults. Recognizes entities, embeddables, and mapped superclasses by their corresponding Jakarta Persistence annotations, excludes transient fields, and preserves the supplied persistent-field ordering. Subclasses may override individual decisions or EnhancementModel.getCandidates() to describe an integration's model scope.

All persistent attributes are eligible for lazy-loading support by default; this preserves the enhancer's existing behavior rather than inferring a fetch plan from annotations. Collection handling recognizes plural mapping annotations and treats otherwise unclassified collection fields as plural unless marked basic.

This implementation is stateless. Mutable discovery results, including implicit embeddable classifications, belong to the session, not this model.

  • Constructor Details

    • DefaultEnhancementModel

      public DefaultEnhancementModel()
  • Method Details

    • isEntityClass

      public boolean isEntityClass(UnloadedClass type)
      Specified by:
      isEntityClass in interface EnhancementModel
      Parameters:
      type - an unloaded class descriptor
      Returns:
      whether the class is an entity within this model
    • isCompositeClass

      public boolean isCompositeClass(UnloadedClass type)
      Description copied from interface: EnhancementModel
      Identifies explicitly known embeddables. Session discovery additionally recognizes types used as embedded attributes, even without an embeddable annotation.
      Specified by:
      isCompositeClass in interface EnhancementModel
      Parameters:
      type - an unloaded class descriptor
      Returns:
      whether the model explicitly recognizes an embeddable class
    • isMappedSuperclassClass

      public boolean isMappedSuperclassClass(UnloadedClass type)
      Specified by:
      isMappedSuperclassClass in interface EnhancementModel
      Parameters:
      type - an unloaded class descriptor
      Returns:
      whether the class supplies persistent state as a mapped superclass
    • isPersistentField

      public boolean isPersistentField(UnloadedField field)
      Description copied from interface: EnhancementModel
      Determines persistent-field eligibility after the enhancer has excluded static fields and its generated implementation fields.
      Specified by:
      isPersistentField in interface EnhancementModel
      Parameters:
      field - an unloaded field descriptor
      Returns:
      whether the field represents persistent state
    • order

      public UnloadedField[] order(UnloadedField[] fields)
      Description copied from interface: EnhancementModel
      Orders persistent fields consistently with the model's attribute ordering. Implementations may reorder the supplied array in place. A replacement array must preserve its runtime component type and contain the supplied descriptors.
      Specified by:
      order in interface EnhancementModel
      Parameters:
      fields - the eligible persistent fields
      Returns:
      those fields in model order
    • hasLazyLoadableAttributes

      public boolean hasLazyLoadableAttributes(UnloadedClass type)
      Specified by:
      hasLazyLoadableAttributes in interface EnhancementModel
      Parameters:
      type - an unloaded class descriptor
      Returns:
      whether the model permits lazy attributes in this class, independently of whether lazy-loading support is enabled in the enhancement options
    • isLazyLoadable

      public boolean isLazyLoadable(UnloadedField field)
      Specified by:
      isLazyLoadable in interface EnhancementModel
      Parameters:
      field - an unloaded persistent-field descriptor
      Returns:
      whether the attribute may be loaded lazily under this model
    • isMappedCollection

      public boolean isMappedCollection(UnloadedField field)
      Description copied from interface: EnhancementModel
      Distinguishes persistent plural attributes from collection-valued basic attributes when the enhancer handles a collection-typed field.
      Specified by:
      isMappedCollection in interface EnhancementModel
      Parameters:
      field - an unloaded persistent-field descriptor
      Returns:
      whether the field should receive persistent-collection handling