use of org.hibernate.metamodel.model.convert.internal.JpaAttributeConverterImpl in project hibernate-orm by hibernate.
the class Converters method jpaAttributeConverter.
/**
* Generates a BasicValueConverter based on an {@link AttributeConverter}
*/
public static <O, R> BasicValueConverter<O, R> jpaAttributeConverter(JavaType<R> relationalJtd, JavaType<O> domainJtd, Class<? extends AttributeConverter<O, R>> converterClass, SessionFactory factory) {
final SessionFactoryImplementor sfi = (SessionFactoryImplementor) factory;
final ManagedBeanRegistry beanRegistry = sfi.getServiceRegistry().getService(ManagedBeanRegistry.class);
final ManagedBean<? extends AttributeConverter<O, R>> converterBean = beanRegistry.getBean(converterClass);
final TypeConfiguration typeConfiguration = sfi.getTypeConfiguration();
final JavaTypeRegistry jtdRegistry = typeConfiguration.getJavaTypeRegistry();
final JavaType<? extends AttributeConverter<O, R>> converterJtd = jtdRegistry.getDescriptor(converterClass);
return new JpaAttributeConverterImpl<>(converterBean, converterJtd, domainJtd, relationalJtd);
}
Aggregations