그래서이 긴 complexe 기본은 SQLQuery 있습니다개의 HQL이 네이티브 SQL 쿼리를 변환하는 방법
string hql =
@"SELECT *
FROM
(SELECT a.*, rownum r__
FROM
(select f2.filmid,
f2.realisateurid,
f2.titre,
f2.annesortie,
f2.langue,
f2.duree,
f2.resume,
f2.poster,
f2.qtytotal,
f2.qtydisponible from film f2
where f2.filmid in (
select distinct f.filmid
from film f, filmpays fp, pays p, filmgenre fg, genre g, informationpersonnel director, role r, informationpersonnel actor
where f.filmid = fp.filmid
and fp.paysid = p.paysid
and f.filmid = fg.filmid
and fg.genreid = g.genreid
and f.realisateurid = director.personelid
and f.filmid = r.filmid
and r.personelid = actor.personelid
and f.qtydisponible > 0
and upper(f.titre) LIKE :titre
and f.annesortie >= :anneeLow AND f.annesortie <= :anneeHigh
and upper(g.Nomgenre) LIKE :genre
and upper(f.Langue) LIKE :langue
and upper(p.Nom) LIKE :pays
and upper(director.nom) LIKE :realisateur
and upper(actor.nom) LIKE :acteur)
order by f2.annesortie DESC, f2.titre) a
WHERE rownum < ((:page * 8) +1))
WHERE r__ >= (((:page - 1) *8) +1) ";
/*Begin transaction */
ITransaction tx = s.BeginTransaction();
IQuery query = s.CreateQuery(hql);
query.SetString("titre", "%" + sp.Title.ToUpper() + "%");
query.SetInt32("anneeLow", sp.YearLow);
query.SetInt32("anneeHigh", sp.YearHigh);
query.SetString("pays", "%" + sp.Country.ToUpper() + "%");
query.SetString("langue", "%" + sp.Lang.ToUpper() + "%");
query.SetString("genre", "%" + sp.Genre.ToUpper() + "%");
query.SetString("realisateur", "%" + sp.Director.ToUpper() + "%");
query.SetString("acteur", "%" + sp.Actor.ToUpper() + "%");
query.SetInt32("page", page);
IList<Film> movies = query.List<Film>();
tx.Commit();
return movies;
을 그리고 난 100 % HQL 방식으로
유사뭔가를 쓰기 위해 노력하고있어 내 쿼리처럼 complexe 다른 선택에서 선택이있는 경우 HQL의 내가 HQL에서 간단한 작은 쿼리를 만드는 방법을 이해하고있는 문서,하지만 컨설팅 후
IList<Cat> moreCats = sess.CreateQuery(
"from Cat as cat where " +
"cat.Name = 'Fritz' or cat.id = :id1 or cat.id = :id2"
).SetInt64("id1", id1)
.SetInt67("id2", id2)
.List<Cat>();
, 어떻게 진행해야합니까?
는
나는 100 번 upvote 할 수 있으면 좋겠다. 시간 내 주셔서 감사합니다. – napi15