# DoubleJdbcType#getDdlTypeCode -\> Types.FLOAT?

**URL:** <https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402>\
**Category:** Hibernate ORM\
**Created:** [March 17, 2023, 8:55am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402 "2023-03-17T08:55:17Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 17, 2023, 8:55am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/1 "2023-03-17T08:55:17Z")

</div>

Hi,

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.

![image](https://canada1.discourse-cdn.com/flex035/uploads/hibernate/original/2X/2/2482c1aa6cdddb00cbf358f9263f37b3838c478a.png)

My solution, override the DoubleJdbcType and DoubleJavaType :

```auto
public class EfluidDoubleJdbcType extends DoubleJdbcType {

  public static final EfluidDoubleJdbcType INSTANCE = new EfluidDoubleJdbcType();

  @Override
  public int getDdlTypeCode() {
    return Types.DOUBLE;
  }
}

```

```auto
public class EfluidDoubleJavaType extends DoubleJavaType {

  public static final EfluidDoubleJavaType INSTANCE = new EfluidDoubleJavaType();

  @Override
  public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
    return EfluidDoubleJdbcType.INSTANCE;
  }
}

```

```auto
public class EfluidTypeContributor implements TypeContributor {

  @Override
  public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    typeContributions.contributeJavaType(EfluidDoubleJavaType.INSTANCE);
    typeContributions.contributeJdbcType(EfluidDoubleJdbcType.INSTANCE);
  }
}

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [March 17, 2023, 1:45pm UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/2 "2023-03-17T13:45:23Z")

</div>

Since you don’t explain what the problem is that you have I can’t really help you. The way this is designed is on purpose.

---

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 17, 2023, 3:08pm UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/3 "2023-03-17T15:08:09Z")

</div>

Yes sorry.

My problem is i must get the format in database of a column for generate the DDL  
And the java type double are `number` type and not `float` int the BDD.

It is a comparison that is expected :

 ![image](https://canada1.discourse-cdn.com/flex035/uploads/hibernate/original/2X/f/f470bc26ea14a97de40054a8a9ed9616d1186a3b.png)

```auto
public class MappingSQLType {

  public static String getSqlType(Column columnHibernate) {
    if (columnHibernate.getValue() instanceof SimpleValue value) {
      return columnHibernate.getSqlType(value.getMetadata());
    }
    return null;
  }
}

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [March 17, 2023, 4:25pm UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/4 "2023-03-17T16:25:33Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 17, 2023, 4:28pm UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/5 "2023-03-17T16:28:48Z")

</div>

It’s a good idea, i will test that. Thank you !

---

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 21, 2023, 9:35am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/6 "2023-03-21T09:35:38Z")

</div>

It’s ok ! 😃  
Thanks.

---

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 22, 2023, 7:54am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/7 "2023-03-22T07:54:21Z")

</div>

The implementation:

```auto
public class EfluidTypeContributor implements TypeContributor {

  @Override
  public void contribute(TypeContributions typeContributions, ServiceRegistry serviceRegistry) {
    typeContributions.contributeJavaType(ListEnumTypeJava.INSTANCE);
    Dialect dialect = serviceRegistry.getService(JdbcEnvironment.class).getDialect();
    typeContributions.getTypeConfiguration().getDdlTypeRegistry().addDescriptor(new DdlTypeImpl(SqlTypes.FLOAT, "number", dialect ));
  }
}

```

---

<div class="post-metadata">

**Author:** ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)\
**Post date:** [March 22, 2023, 8:06am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/8 "2023-03-22T08:06:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boutss](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/boutss/32/1543_2.png) [@boutss](https://discourse.hibernate.org/u/boutss)\
**Post date:** [March 22, 2023, 8:38am UTC](https://discourse.hibernate.org/t/doublejdbctype-getddltypecode-types-float/7402/9 "2023-03-22T08:38:59Z")

</div>

Sorry, it’s a enum custom from us framework, not the java enum.

```auto
public class ListEnum<T extends EnumerationType> implements Serializable, Cloneable, Iterable<T> {

```
