作爲HQL的初學者,我有一個SQL查詢,我試圖轉換成hql。HQL語法錯誤:'NHibernate.Hql.Ast.ANTLR.QuerySyntaxException'
select * from (
select *
from CORRELATION_VUE
where film = v_oldidfilm and FILM2 not in (
select c.idfilm
from cotes c
where idclient = v_idclient)
order by CORRELATION desc
)
where rownum <= 3;
所以在HQL我想這一點:
ISession s = NHibernateHelper.GetCurrentSession();
ITransaction tx = s.BeginTransaction();
IQuery query = s.CreateQuery(
@"select u from (
select u from vueCorreliser u
where u.film = :idfilm
and u.FILM2 not in (
select c.idfilm from cote c
where c.idclient = :idclient)
order by u.CORRELATION desc)
where rownum <= 3; ")
.SetInt32("idfilm", idfilm)
.SetInt32("idclient", idclient);
IList<Film> result = query.List<Film>();
tx.Commit();
return result;
但我對CreateQuery
線路接收語法錯誤。
我做錯了什麼?
謝謝
同樣的麻煩,比你在這[其他問題](/ q/42462497/1178314)! –
[如何將此原生SQL查詢轉換爲HQL]可能的重複(http://stackoverflow.com/questions/42462497/how-to-transform-this-native-sql-query-to-an-hql) –