DB2400Dialect: Dialect does not support variable limits.

227 views
Skip to first unread message

tlum

unread,
Mar 29, 2012, 10:12:53 AM3/29/12
to nhu...@googlegroups.com
One of my DB repository methods is now throwing:

System.NotSupportedException: Dialect does not support variable limits.
  at
NHibernate.Dialect.Dialect.GetLimitString(SqlString queryString, Nullable`1 offset, Nullable`1 limit, Parameter offsetParameter, Parameter limitParameter)
  at
NHibernate.Hql.Ast.ANTLR.SqlGenerator.GetSqlStringWithLimitsIfNeeded(QueryWriter queryWriter)
  at
NHibernate.Hql.Ast.ANTLR.SqlGenerator.EndQuery()
  at
NHibernate.Hql.Ast.ANTLR.SqlGenerator.selectStatement()
  at
NHibernate.Hql.Ast.ANTLR.SqlGenerator.statement()
  at
NHibernate.Hql.Ast.ANTLR.HqlSqlGenerator.Generate()
 
.
 
.
 
.

I have noticed this comment on the source:

Removed all but one Dialect GetLimitString method. (Breaking Change)
Various limit-related simplifications, bug fixes, and improvements.


And see this change:

-    public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit, int? offsetParameterIndex, int? limitParameterIndex)
+        public override SqlString GetLimitString(SqlString querySqlString, SqlString offset, SqlString limit)

Is this an NHibernate bug? is there away around this?

tlum

unread,
Mar 29, 2012, 11:54:39 AM3/29/12
to nhu...@googlegroups.com
BTW, this is the Expression Debug string from the NHibernate.Linq.DefaultQueryProvider call:

 .Call System.Linq.Queryable.Take(\r\n
    .Call System.Linq.Queryable.Skip(\r\n
        .Call System.Linq.Queryable.OrderBy(\r\n
            .Constant<NHibernate.Linq.NhQueryable`1[SolutionExample.Domain.Principal]>(NHibernate.Linq.NhQueryable`1[SolutionExample.Domain.Principal]),\r\n
            '(.Lambda #Lambda1<System.Func`2[SolutionExample.Domain.Principal,System.String]>)),\r\n
        0),\r\n
    25)\r\n
\r\n
.Lambda #Lambda1<System.Func`2[SolutionExample.Domain.Principal,System.String]>(SolutionExample.Domain.Principal $o) {\r\n
    .Call ($o.PrincipalName).ToLower()\r\n

tlum

unread,
Mar 29, 2012, 8:29:40 PM3/29/12
to nhu...@googlegroups.com
I have screwed up the question. I am working with 3.2.GA. The code and comments that I referred to in the original question do not apply to 3.2GA, they happen later. Version 3.2GA still accepts multiple 'skip' and 'take' formats and simply throws an exception if the one the caller chose is not supported by the dialect. Is there a way, through a configuration parameter or something, to have the SQLGenerator not try and ask for a parametrized 'skip' and 'take' when the dialect does not support it? As far as I know you can't specify that when using the Linq provider so I'm not sure how to resolve this.


On Thursday, March 29, 2012 10:12:53 AM UTC-4, tlum wrote:

tlum

unread,
Mar 29, 2012, 10:07:03 PM3/29/12
to nhu...@googlegroups.com
After much research I've decided that while I could solve this question by either creating my own custom dialect that implements - or extending the existing DB2400Dialect to implement -

    public SqlString GetLimitString(SqlString queryString, int? offset, int? limit, Parameter offsetParameter, Parameter limitParameter)

that would be pointless since while the iSeries allows a limit with the

    ... FETCH FIRST n ROWS ONLY

syntax, it has no equivalent syntax for doing an offset... so, there isn't much point to fixing the broken bits.


On Thursday, March 29, 2012 10:12:53 AM UTC-4, tlum wrote:
Reply all
Reply to author
Forward
0 new messages