1

When the JOOQ generator generates the records using database tables, It maps the 'float' type column to Double instead of Float Why?

Database: MySQL,

Create statement:

CREATE TABLE `product_attribute` (
  `id` int NOT NULL auto_increment,
  `value` float DEFAULT NULL,
  PRIMARY KEY (`id`)
)
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509
Sai Uttej
  • 199
  • 7

1 Answers1

2

The various SQL dialects have slightly different interpretations of what is a REAL, FLOAT, and DOUBLE PRECISION data type, and so does JDBC.

In MySQL, a FLOAT type is a varying precision floating point number, so it can correspond to both java.lang.Float or java.lang.Double. To play safe, jOOQ uses the higher precision representation in order not to lose any data when reading from the database.

If you want an actual java.lang.Float representation, then use MySQL's REAL data type instead, with the appropriate precision.

Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509