Package org.hibernate.binder

Interface TypeBinder<A extendsAnnotation>

  • All Known Implementing Classes:
    BatchSizeBinder,CommentBinder,CommentsBinder,DiscriminatorOptionsBinder

    @Incubatingpublic interfaceTypeBinder<A extendsAnnotation>
    Allows a user-written annotation to drive some customized model binding.

    An implementation of this interface interacts directly with model objects likePersistentClass andComponent to implement the semantics of somecustom mapping annotation.

    For example, this annotation disables rowcount checking for insert, update, and delete statements for annotated entities:

     @TypeBinderType(binder = NoResultCheck.Binder.class) @Target(TYPE) @Retention(RUNTIME) public @interface NoResultCheck {     class Binder implements TypeBinder<NoResultCheck> {         @Override         public void bind(NoResultCheck annotation,                 MetadataBuildingContext buildingContext,                 PersistentClass persistentClass) {             persistentClass.setInsertCheckStyle(NONE);             persistentClass.setUpdateCheckStyle(NONE);             persistentClass.setDeleteCheckStyle(NONE);         }         @Override         public void bind(NoResultCheck annotation,                 MetadataBuildingContext buildingContext,                 Component embeddableClass) {             throw new AnnotationException("'@NoResultCheck' cannot annotate an '@Embeddable' class");         }     } }
    See Also:
    TypeBinderType,AttributeBinder
    • Method Detail

      • bind

        void bind​(A annotation,MetadataBuildingContext buildingContext,PersistentClass persistentClass)
        Perform some custom configuration of the model relating to the given annotatedentity class.
        Parameters:
        annotation - an annotation of the entity class that is declared as anTypeBinderType
        persistentClass - the entity class
      • bind

        void bind​(A annotation,MetadataBuildingContext buildingContext,Component embeddableClass)
        Perform some custom configuration of the model relating to the given annotatedembeddable class.
        Parameters:
        annotation - an annotation of the embeddable class that is declared as anTypeBinderType
        embeddableClass - the embeddable class