Dear Hibernate Team, The Oracle JDBC Driver generally returns a value of “-127” for method "getScale()" and a value of “0” for method "getPrecision()" (on “OracleResultSetMetaData”) in case the scale and the precision of a returned numeric column is unknown. Starting with Hibernate 6, Hibernate will return the data as Float data type (according to “'org.hibernate.dialect.OracleDialect.resolveSqlTypeDescriptor()”) instead of BigDecimal (in previous versions). From my point of view, this is a pretty bad design decision as it:
- breaks existing code which uses native queries (which do not feature explicit type mappings via ‘addScalar’)
- even worse: causes loss in predictability and loss in precision, e.g., a SQL query like:
SELECT col1 FROM testTable UNION ALL 123.54356 AS col1 FROM DUAL will return “col1” as Float value EVEN if you specify “col1” as NUMBER(38,0)!! Data loss is garuanteed. Basically it means, that SQL queries that do not look as being problematic at the first glance, may reveal as such at a much closer look. If code features hundreds of native queries, you need to closely inspect each of them (not that I’m a big fan of native queries but sometimes it is was it is…) If Oracle returns a value of “-127” for method "getScale()" and a value of “0” for method "getPrecision() it simply mean that precision and scale are unknown and in such case using BigDecimal is the right decision whereas Float data type is definitely not. Bye, Ralf |