Well, I've been looking around the code for a while and found the solution in adding a little modification to
org/hibernate/dialect/FirebirdDialect.java
Code:
public String getLimitString(String sql, boolean hasOffset) {
return new StringBuffer( sql.length()+20 )
.append(sql)
.insert(6, hasOffset ? " first ? skip ?" : " first ?")
.toString();
}
to look like this:
Code:
public String getLimitString(String sql, boolean hasOffset) {
return new StringBuffer( sql.length()+20 )
.append(sql)
.insert(sql.toLowerCase().indexOf( "select" ) + 6, hasOffset ? " first ? skip ?" : " first ?")
.toString();
}
It was already working on HSQLDialect, actually.
Hope this change will appear in next release cause comments are a really interesting thing in order to debug a program.