我有2个表:Claim和Type_Claim。声明在Type_Claim上有一个外部密钥。在Hibernate上,表示Claim表的Bean具有TypeClaim作为属性。Hibernate HqlL:Count和Group By包含零?
Claim
ID TYPE
1 2
2 2
3 4
4 1
Type_Claim
ID Description
1 "Hello"
2 "Hi"
3 "House"
4 "Welcome"
5 "Bye"
现在,我做了这个查询:
SELECT tc.description, COUNT(*)
FROM Claim claim"
LEFT OUTER JOIN claim.typeClaim tc
GROUP BY tc.description ";
我想获得此:
Description Count
"Hello" 1
"Hi" 2
"House" 0
"Welcome" 1
"Bye" 0
但我得到这样的:
Description Count
"Hello" 1
"Hi" 2
"Welcome" 1
如何Ç我在查询中包含0个结果?我尝试了RIGHT JOIN,但得到了同样的结果。
可能复制[用mysql group显示count为0的行](http://stackoverflow.com/questions/743456/displaying-rows-with-count-0-with-mysql-group-by) – Dazak
应该使用右边加入。你能发布生成的SQL吗? –