开发者

Syntax error on multi query in NHibernate 3 and MySQL

开发者 https://www.devze.com 2023-01-28 23:34 出处:网络
I used to be able to run the following code as a multi query in NHibernate 2.1 using MySQL var total = new LeagueInfoQuery { Count = true, User = CurrentUser }.CreateCriteria(session).FutureValue<

I used to be able to run the following code as a multi query in NHibernate 2.1 using MySQL

var total = new LeagueInfoQuery { Count = true, User = CurrentUser }.CreateCriteria(session).FutureValue<int>();
var leagues = new LeagueInfoQuery { User = CurrentUser, PageSize = pageSize, Page = page, SortBy = sortBy, SortAsc = sortAsc }.CreateCriteria(session).Future<LeagueInfo>();
var results = PaginationHelper.CreateCustomPage<LeagueInfo>(leagues, pageSize, page, total.Value);

where e.g. LeagueInfoQuery is just a custom query object that can create a standard ICriteria.

However, since upgrading to NHibernate 3.0 I now get a syntax error. The exception message is as follows.

{"Error executing multi criteria : [SEL开发者_JAVA技巧ECT count(*) as y0_ FROM League this_ WHERE this_.User = ?p0;\r\nSELECT this_.Id as y0_, this_.Name as y1_, min(f1_.Date) as y2_, max(f1_.Date) as y3_, count(distinct t2_.Id) as y4_ FROM League this_ inner join Team t2_ on this_.Id=t2_.League inner join Fixture f1_ on this_.Id=f1_.League WHERE this_.User = ?p1 GROUP BY this_.Name ORDER BY y0_ desc limit ?p1;\r\n]"}

Inner Exception:

{"You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''b68d9d4e-a958-4fb8-8490-9e4401572f38'' at line 1"}

So it looks like a syntax error but this didn't use to happen in v2.1 and if I edit the SQL in the message so that the parameters are values I can get it to work.

So why is this error now occurring in NHibernate 3.0? Do I need to configure something in particular for MySQL syntax and if so what?

Cheers.


This was an issue with NHibernate 3 which has now been resolved (thanks!)

0

精彩评论

暂无评论...
验证码 换一张
取 消