I have a problem with the double type conversion to DDL because the method Double JdbcType#getDdlTypeCode return Types.FLOAT.
It’s volontary? I think yes but i don’t undestrand.
Thank you.
My solution, override the DoubleJdbcType and DoubleJavaType :
public class EfluidDoubleJdbcType extends DoubleJdbcType {
public static final EfluidDoubleJdbcType INSTANCE = new EfluidDoubleJdbcType();
@Override
public int getDdlTypeCode() {
return Types.DOUBLE;
}
}
public class EfluidDoubleJavaType extends DoubleJavaType {
public static final EfluidDoubleJavaType INSTANCE = new EfluidDoubleJavaType();
@Override
public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
return EfluidDoubleJdbcType.INSTANCE;
}
}
public class EfluidTypeContributor implements TypeContributor {
@Override
public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
typeContributions.contributeJavaType(EfluidDoubleJavaType.INSTANCE);
typeContributions.contributeJdbcType(EfluidDoubleJdbcType.INSTANCE);
}
}
Well, if you want to map your Double fields in the database as number DDL type, then I would recommend you to do that on a per-field basis with @Column(columnDefinition). If you have many columns and want all of them to use the same mapping, you can register that in the DdlTypeRegisty, by calling addDescriptor( new DdlTypeImpl( SqlTypes.FLOAT, "number", dialect ) ) within e.g. a custom org.hibernate.boot.model.TypeContributor
Can you explain why you need a ListEnumTypeJava? Hibernate 6.2 properly supports stuff like @Basic List<MyEnum> already and maps that to e.g. tinyint array or smallint array on the DB if possible, and falls back to varbinary if the DB does not support arrays natively.