From 4ebc24daa004422e5be2da2f16190d85feef0412 Mon Sep 17 00:00:00 2001 From: Gavin Date: Sun, 21 May 2023 17:13:38 +0200 Subject: [PATCH] HHH-16650 add test --- .../test/query/OracleNumericTypesTest.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 hibernate-core/src/test/java/org/hibernate/orm/test/query/OracleNumericTypesTest.java diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/OracleNumericTypesTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/OracleNumericTypesTest.java new file mode 100644 index 0000000000..b14c499771 --- /dev/null +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/OracleNumericTypesTest.java @@ -0,0 +1,29 @@ +package org.hibernate.orm.test.query; + +import org.hibernate.dialect.OracleDialect; +import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.JiraKey; +import org.hibernate.testing.orm.junit.RequiresDialect; +import org.hibernate.testing.orm.junit.SessionFactory; +import org.hibernate.testing.orm.junit.SessionFactoryScope; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertInstanceOf; + +@SessionFactory +@DomainModel +@RequiresDialect(OracleDialect.class) +@JiraKey("HHH-16650") +public class OracleNumericTypesTest { + @Test void test(SessionFactoryScope scope) { + String sql = "SELECT 012345678901234567890123456789, cast(1234567890123.456 as number(30,5)), cast(1234567890123.456 as double precision), cast(1234567890123.456 as float(32)), cast(1234567890123.456 as float(24)) from dual"; + Object[] values = scope.fromSession( s -> s.createNativeQuery(sql, Object[].class).getSingleResult()); + assertInstanceOf(BigDecimal.class, values[0]); + assertInstanceOf(BigDecimal.class, values[1]); + assertInstanceOf(BigDecimal.class, values[2]); + assertInstanceOf(Double.class, values[3]); + assertInstanceOf(Float.class, values[4]); + } +}