The intended way is to register a custom org.hibernate.type.descriptor.java.JavaTypeDescriptor
with the JavaTypeDescriptorRegistry
. Then the AttributeConverter would simply work.
The JavaTypeDescriptorRegistry
can be accessed from the org.hibernate.type.spi.TypeConfiguration
which in turn can be accessed via:
org.hibernate.boot.internal.BootstrapContextImpl#getTypeConfiguration
-
SessionFactoryImplementor#getMetamodel
->MetamodelImplementor#getTypeConfiguration
org.hibernate.boot.spi.MetadataImplementor#getTypeConfiguration
depending on where you are in the SessionFactory lifecycle.
The easiest way to register JavaTypeDescriptor (or other type system extensions) is a custom org.hibernate.boot.model.TypeContributor
implementation which Hibernate will discover using Java’s standard ServiceLoader
mechanism.