we were moving our app from Spring Boot 2.7 to 3 and noticed some changes in the type behavior in Hibernate 6.
We have some native queries with lists of Objects as result, so there are no definded types in entity classes.
// example
public List<List<Object>> findResults()
{
Query query = entityManager.createNativeQuery("select number1, number2 from table");
return query.getResultList();
}
With Hibernate 5 it would map all NUMBER types from the Oracle DB to BigDecimal.
Now with Hibernate 6 this has changed: It maps the type depending on the NUMBER column’s precition and scale:
I don’t know what you tested, but the latest OracleDialect in Hibernate ORM 6.2.0.Final does not map NUMBER(1,0) to Boolean anymore. The mapping to FLOAT is a special case that only happens if JDBC reports a scale of -127, which seems to be a special value that indicates float semantics.
The JPA specification doesn’t say anything about how we should interpret native query results when no result set mapping is given. Usually, we try to follow map native query results similar to how we would generate a schema though. Since we generate NUMBER(10,0) for persistent attributes of type Integer, we try to map that back to Integer then also.