From dd80b3e2a5eb44d6dbeebbe19b5065aa73485e16 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 18 Nov 2024 20:49:46 +0100 Subject: [PATCH] HHH-18859 add a test for string slice operator --- .../orm/test/query/hql/FunctionTests.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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 f0aa28a40c..797a97ee99 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 @@ -2526,6 +2526,23 @@ public class FunctionTests { ); } + @Test + public void testSlice(SessionFactoryScope scope) { + scope.inTransaction( + session -> { + assertEquals("ring", + session.createSelectionQuery("select theString[3:6] from EntityOfBasics", String.class) + .getSingleResult()); + assertEquals('s', + session.createSelectionQuery("select theString[1] from EntityOfBasics", Character.class) + .getSingleResult()); + assertEquals('y', + session.createSelectionQuery("select theString[7] from EntityOfBasics", Character.class) + .getSingleResult()); + } + ); + } + @Test @SkipForDialect(dialectClass = H2Dialect.class) @SkipForDialect(dialectClass = DerbyDialect.class)