类
public class Client {
//历史订单
List orders;
}
public class Order{
// 订单日期
Date date;
}
要求是 查询 client 最后一次订单 的日期 是6个月前
我不知道hql该怎样写 不要sql 是hql
类
public class Client {
//历史订单
List orders;
}
public class Order{
// 订单日期
Date date;
}
要求是 查询 client 最后一次订单 的日期 是6个月前
我不知道hql该怎样写 不要sql 是hql
查询 : 最后一次订单 的日期 在6个月前 的Client
使用hql子查询
--我用我的 '用户' 和 '登录日志' 做测试OK,下面是我的测试hql
from UserInfo u
where (
select count(*) from u.loginLogs l
where l.loginTime>'2008-12-24 20:01:39.217'
)=0"
--同理换成你 'Client' 和 'Order', hql语句如下
[i]from Client c
where (
select count(*) from c.orders o
where o.date>'2008-12-07 23:59:59.999'
)=0[/i]
分析:
查询:自从2008-12-07之后(距离今天6个月) 其订单的 数量为0的Client
(查询结果包括从来没有下过订单的Client)