Search code examples
springspring-boothibernatehibernate-6.x

Hibernate 6.x.x CALCULATED FIELDS in createNativeQuery (oracle) doExtract integer insted of BigDecimals


The Oracle PL/SQL Native SUM function (calcaulated field) is not working as expected, it is converting float to integer values, the next is a following example:

@Override
public ArrayList<Object[]> testSUMError() {
    Session session = sessionFactory.getCurrentSession();
    
    Query objQuery = session.createNativeQuery("""
        SELECT 
            19.80 COLUMN_OK, \
            SUM(39.74) COLUMN_FAIL \
        FROM DUAL                                                                      
    """, Object.class);
    
    return (ArrayList<Object[]>) objQuery.list();
}

If we test the SELECT the return object is:

result of the SELECT

as you can see, the 39 is not even rounding, it only deletes the decimals.

Entorno Hibernate-core 6.2.2.Final Java 17 Jakarta 10 Spring Boot 3.1.0

I make the bug report to Hibernate but no luck with any dev, and I need to find a solution, without editting the Query.

https://hibernate.atlassian.net/jira/software/c/projects/HHH/issues/HHH-16697


Solution

  • Fixed at: https://hibernate.atlassian.net/jira/software/c/projects/HHH/issues/HHH-16697

    At.: Hibernate-6.2.5.Final