Class ClassImportIntegrator

java.lang.Object
io.hypersistence.utils.hibernate.type.util.ClassImportIntegrator
All Implemented Interfaces:
org.hibernate.integrator.spi.Integrator

public class ClassImportIntegrator extends Object implements org.hibernate.integrator.spi.Integrator
The ClassImportIntegrator implements the Hibernate Integrator contract and allows you to provide a List of classes to be imported using their simple name. For instance, you could use a DTO simple class name, instead of the fully-qualified name when building a constructor expression in a JPQL query. For more details about how to use it, check out this article on vladmihalcea.com.
Author:
Vlad Mihalcea
  • Constructor Summary

    Constructors
    Constructor
    Description
    ClassImportIntegrator(List<? extends Class> classImportList)
    Builds a new integrator that can register the provided classes.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    disintegrate(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry)
    Exclude the provided parent path and register the remaining relative path.
    void
    integrate(org.hibernate.boot.Metadata metadata, org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry)
    Register the provided classes by their simple name or relative package and class name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.hibernate.integrator.spi.Integrator

    integrate
  • Constructor Details

    • ClassImportIntegrator

      public ClassImportIntegrator(List<? extends Class> classImportList)
      Builds a new integrator that can register the provided classes.
      Parameters:
      classImportList - list of classes to be imported
  • Method Details

    • excludePath

      public ClassImportIntegrator excludePath(String path)
      Exclude the provided parent path and register the remaining relative path. If the excludedPath is not set, then the package is excluded and only the simple class name is registered. For instance, if you provide the io.hypersistence.utils.hibernate.type path, and register a class whose fully-qualified name is io.hypersistence.utils.hibernate.type.json.PostDTO, then the class is going to be registered under the json.PostDTO alias.
      Parameters:
      path - path to be excluded.
      Returns:
      the ClassImportIntegrator object reference
    • integrate

      public void integrate(org.hibernate.boot.Metadata metadata, org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry)
      Register the provided classes by their simple name or relative package and class name.
      Specified by:
      integrate in interface org.hibernate.integrator.spi.Integrator
      Parameters:
      metadata - metadata
      sessionFactory - Hibernate session factory
      serviceRegistry - Hibernate service registry
    • disintegrate

      public void disintegrate(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry)
      Specified by:
      disintegrate in interface org.hibernate.integrator.spi.Integrator