Search in sources :

Example 1 with AnyKeyJdbcType

use of org.hibernate.annotations.AnyKeyJdbcType in project hibernate-orm by hibernate.

the class BasicValueBinder method prepareAnyKey.

private void prepareAnyKey(XProperty modelXProperty) {
    implicitJavaTypeAccess = (typeConfiguration) -> null;
    explicitJavaTypeAccess = (typeConfiguration) -> {
        final AnyKeyJavaType javaTypeAnn = findAnnotation(modelXProperty, AnyKeyJavaType.class);
        if (javaTypeAnn != null) {
            final Class<? extends BasicJavaType<?>> javaType = normalizeJavaType(javaTypeAnn.value());
            if (javaType != null) {
                return getManagedBeanRegistry().getBean(javaType).getBeanInstance();
            }
        }
        final AnyKeyJavaClass javaClassAnn = findAnnotation(modelXProperty, AnyKeyJavaClass.class);
        if (javaClassAnn != null) {
            // noinspection rawtypes
            return (BasicJavaType) typeConfiguration.getJavaTypeRegistry().getDescriptor(javaClassAnn.value());
        }
        return null;
    };
    explicitJdbcTypeAccess = (typeConfiguration) -> {
        final AnyKeyJdbcType jdbcTypeAnn = findAnnotation(modelXProperty, AnyKeyJdbcType.class);
        if (jdbcTypeAnn != null) {
            final Class<? extends JdbcType> jdbcType = normalizeJdbcType(jdbcTypeAnn.value());
            if (jdbcType != null) {
                final ManagedBean<? extends JdbcType> jtdBean = getManagedBeanRegistry().getBean(jdbcType);
                return jtdBean.getBeanInstance();
            }
        }
        final AnyKeyJdbcTypeCode jdbcTypeCodeAnn = findAnnotation(modelXProperty, AnyKeyJdbcTypeCode.class);
        if (jdbcTypeCodeAnn != null) {
            if (jdbcTypeCodeAnn.value() != Integer.MIN_VALUE) {
                return typeConfiguration.getJdbcTypeRegistry().getDescriptor(jdbcTypeCodeAnn.value());
            }
        }
        return null;
    };
}
Also used : BasicJavaType(org.hibernate.type.descriptor.java.BasicJavaType) AnyKeyJdbcTypeCode(org.hibernate.annotations.AnyKeyJdbcTypeCode) AnyKeyJdbcType(org.hibernate.annotations.AnyKeyJdbcType) AnyKeyJavaType(org.hibernate.annotations.AnyKeyJavaType) AnyKeyJavaClass(org.hibernate.annotations.AnyKeyJavaClass)

Aggregations

AnyKeyJavaClass (org.hibernate.annotations.AnyKeyJavaClass)1 AnyKeyJavaType (org.hibernate.annotations.AnyKeyJavaType)1 AnyKeyJdbcType (org.hibernate.annotations.AnyKeyJdbcType)1 AnyKeyJdbcTypeCode (org.hibernate.annotations.AnyKeyJdbcTypeCode)1 BasicJavaType (org.hibernate.type.descriptor.java.BasicJavaType)1