diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/NativeQueryLimitOffsetTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/NativeQueryLimitOffsetTest.java index baa0d885f8..ba33b6129d 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/NativeQueryLimitOffsetTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/NativeQueryLimitOffsetTest.java @@ -12,6 +12,7 @@ import jakarta.persistence.Entity; import jakarta.persistence.Id; import org.hibernate.testing.orm.junit.DomainModel; +import org.hibernate.testing.orm.junit.Jira; import org.hibernate.testing.orm.junit.JiraKey; import org.hibernate.testing.orm.junit.SessionFactory; import org.hibernate.testing.orm.junit.SessionFactoryScope; @@ -91,6 +92,24 @@ public class NativeQueryLimitOffsetTest { ); } + @Test + @Jira( "https://hibernate.atlassian.net/browse/HHH-18309" ) + public void testLimitOffsetZeroValue(SessionFactoryScope scope) { + scope.inTransaction( session -> { + List l = session.createNativeQuery( "select id from Person where name like :name", Long.class ) + .setParameter( "name", "J%" ) + .setFirstResult( 0 ) + .getResultList(); + assertEquals( 5, l.size() ); + + l = session.createNativeQuery( "select id from Person where name like :name", Long.class ) + .setParameter( "name", "J%" ) + .setMaxResults( 0 ) + .getResultList(); + assertEquals( 0, l.size() ); + } ); + } + @Entity(name = "Person") public static class Person { @Id