NHibernate 2nd lvl cache, custom query, sqldialect

前端 未结 7 1062
遥遥无期
遥遥无期 2020-12-21 06:59

I got trunk version of NH and FNH. When i try to add 2nd level cache, some parts of NHibernate forgets about chosen sqldialect.


Initial configuration:

相关标签:
7条回答
  • 2020-12-21 07:47

    Just had the same problem using a similar query which has a WITH clause.

    Unfortunately, my query populates a grid, with paging, so I have to keep SetMaxResults.

    My solution was to rewrite using a Derived Table:

    var sql = @"with Foo(col1,col2,col3)
                  as (select x1, x2, x3 from x join y blabla)
                Select col1, col2, col3 from Foo
                join B on B.col1 = Foo.col1";
    

    becomes

    var sql = @"Select col1, col2, col3 from 
               (select x1 as col1, x2 as col2, x3 as col3 
                from x join y blabla) as Foo
               join B on B.col1 = Foo.col1";
    

    Just to allow NHibernate to insert the " TOP x " string after the "select" string (6 characters from the begining)... No comment :(

    T

    0 讨论(0)
提交回复
热议问题