diff --git a/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java b/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java index ed93e37568..f482a0da9d 100644 --- a/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java +++ b/core/src/main/java/org/hibernate/dialect/DB2390Dialect.java @@ -59,6 +59,9 @@ public class DB2390Dialect extends DB2Dialect { if ( offset > 0 ) { throw new UnsupportedOperationException( "query result offset is not supported" ); } + if ( limit == 0 ) { + return sql; + } return new StringBuffer( sql.length() + 40 ) .append( sql ) .append( " fetch first " ) diff --git a/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java b/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java index c7d9e3bdd3..77f7c54329 100644 --- a/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java +++ b/core/src/main/java/org/hibernate/dialect/DB2400Dialect.java @@ -59,6 +59,9 @@ public class DB2400Dialect extends DB2Dialect { if ( offset > 0 ) { throw new UnsupportedOperationException( "query result offset is not supported" ); } + if ( limit == 0 ) { + return sql; + } return new StringBuffer( sql.length() + 40 ) .append( sql ) .append( " fetch first " )