【发布时间】:2011-07-26 15:41:20
【问题描述】:
HQL 查询
select a from Article a join a.tags t
where t.name in (:tags)
group by a
having count(t)=:tag_count
在 Grails 中使用 HSQLDB 会产生 SqlException“不在聚合函数中...”。查看生成的 SQL 提供
SELECT a.id, a.title, a.url, ....
..
GROUP BY a.id
HAVING ..
我听说在某些 MySQL 产品中可以这样做,但在 HSQLDB 中显然不行。我不明白:
- 为什么 Hibernate 会生成错误的 SQL?还是没有?
- 为什么 HSQLDB 在选择批次时不允许仅对 id 进行分组,我的意思是它毕竟是主键,而且我的 SELECT 不会引入不确定值,例如随机或当前时间
【问题讨论】:
标签: hibernate grails hql hsqldb