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
ConstructorsConstructorDescriptionClassImportIntegrator(List<? extends Class> classImportList) Builds a new integrator that can register the provided classes. -
Method Summary
Modifier and TypeMethodDescriptionvoiddisintegrate(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry) excludePath(String path) Exclude the provided parent path and register the remaining relative path.voidintegrate(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, waitMethods inherited from interface org.hibernate.integrator.spi.Integrator
integrate
-
Constructor Details
-
ClassImportIntegrator
Builds a new integrator that can register the provided classes.- Parameters:
classImportList- list of classes to be imported
-
-
Method Details
-
excludePath
Exclude the provided parent path and register the remaining relative path. If theexcludedPathis not set, then the package is excluded and only the simple class name is registered. For instance, if you provide theio.hypersistence.utils.hibernate.typepath, and register a class whose fully-qualified name isio.hypersistence.utils.hibernate.type.json.PostDTO, then the class is going to be registered under thejson.PostDTOalias.- Parameters:
path- path to be excluded.- Returns:
- the
ClassImportIntegratorobject 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:
integratein interfaceorg.hibernate.integrator.spi.Integrator- Parameters:
metadata- metadatasessionFactory- Hibernate session factoryserviceRegistry- Hibernate service registry
-
disintegrate
public void disintegrate(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry) - Specified by:
disintegratein interfaceorg.hibernate.integrator.spi.Integrator
-