diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java index 0da4202126..24e3053aa2 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java @@ -625,13 +625,11 @@ public class FunctionTests { assertThat( session.createQuery("select cast('123' as Integer)").getSingleResult(), is(123) ); assertThat( session.createQuery("select cast('123' as Long)").getSingleResult(), is(123l) ); assertThat( session.createQuery("select cast('123.12' as Float)").getSingleResult(), is(123.12f) ); -// assertThat( session.createQuery("select cast('123.12' as Double)").getSingleResult(), is(123.12d) ); assertThat( session.createQuery("select cast('hello' as String)").getSingleResult(), is("hello") ); assertThat( ((String) session.createQuery("select cast(true as String)").getSingleResult()).toLowerCase(), is("true") ); assertThat( ((String) session.createQuery("select cast(false as String)").getSingleResult()).toLowerCase(), is("false") ); assertThat( session.createQuery("select cast(123 as String)").getSingleResult(), is("123") ); -// assertThat( session.createQuery("select cast(123.12 as String)").getSingleResult(), is("123.12") ); assertThat( session.createQuery("select cast('1911-10-09' as LocalDate)").getSingleResult(), is(LocalDate.of(1911,10,9)) ); assertThat( session.createQuery("select cast('12:13:14' as LocalTime)").getSingleResult(), is(LocalTime.of(12,13,14)) ); @@ -659,6 +657,20 @@ public class FunctionTests { ); } + @Test + public void testCastDoubleToString(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + assertThat( session.createQuery("select str(123.12)").getSingleResult(), is("123.12") ); + assertThat( session.createQuery("select cast(123.12 as String)").getSingleResult(), is("123.12") ); + assertThat( session.createQuery("select cast(123.12d as String)").getSingleResult(), is("123.12") ); + assertThat( session.createQuery("select cast(123.12f as String)").getSingleResult(), is("123.12") ); + assertThat( session.createQuery("select cast('123.12' as Double)").getSingleResult(), is(123.12d) ); + assertThat( session.createQuery("select cast('123.12' as Float)").getSingleResult(), is(123.12f) ); + } + ); + } + @Test @RequiresDialectFeature( feature = DialectFeatureChecks.SupportsTruncateThroughCast.class) public void testCastFunction_withTruncation(SessionFactoryScope scope) {