Class ClassImportIntegrator
- java.lang.Object
-
- com.vladmihalcea.hibernate.type.util.ClassImportIntegrator
-
- All Implemented Interfaces:
org.hibernate.integrator.spi.Integrator
public class ClassImportIntegrator extends java.lang.Object implements org.hibernate.integrator.spi.Integrator
TheClassImportIntegrator
implements the HibernateIntegrator
contract and allows you to provide aList
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.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<? extends java.lang.Class>
classImportList
private static java.lang.String
DOT
private java.lang.String
excludedPath
-
Constructor Summary
Constructors Constructor Description ClassImportIntegrator(java.util.List<? extends java.lang.Class> classImportList)
Builds a new integrator that can register the provided classes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
disintegrate(org.hibernate.engine.spi.SessionFactoryImplementor sessionFactory, org.hibernate.service.spi.SessionFactoryServiceRegistry serviceRegistry)
ClassImportIntegrator
excludePath(java.lang.String path)
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.
-
-
-
Field Detail
-
DOT
private static final java.lang.String DOT
- See Also:
- Constant Field Values
-
classImportList
private final java.util.List<? extends java.lang.Class> classImportList
-
excludedPath
private java.lang.String excludedPath
-
-
Method Detail
-
excludePath
public ClassImportIntegrator excludePath(java.lang.String path)
Exclude the provided parent path and register the remaining relative path. If theexcludedPath
is not set, then the package is excluded and only the simple class name is registered. For instance, if you provide thecom.vladmihalcea.hibernate.type
path, and register a class whose fully-qualified name iscom.vladmihalcea.hibernate.type.json.PostDTO
, then the class is going to be registered under thejson.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 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:
disintegrate
in interfaceorg.hibernate.integrator.spi.Integrator
-
-