必须将以下工作查询转换为hql查询。产品和汽车是领域。
Product {
long id
hasmany car: Car
string code
}
Car {
int no
int value
}
select p.id from products p
inner join car c on c.id=p.id and p.code='car'
inner join car cr on cr.id=p.id and p.code='car'
where c.no=1 and c.value>=10 and c.no=2 and c.value<=30
答案 0 :(得分:0)
查看模型的定义,应该足以执行以下查询
var query = session.CreateQuery("select p.id from Product p join p.car c" +
" where c.no=1 " +
" and c.value>=10 " +
" and c.no=2 " +
" and c.value<=30 " +
" and p.code='car' ");
var results = query.List<int>();
session
是ISession
接口的实例。