hibernate hql distinct
2008-08-03 14:15
hibernate hql distinct
在 hibernate的reference 中提到過hql是可以直接使用distinct的

--
關鍵字distinct與all 也可以使用,它們具有與SQL相同的語義.
select distinct cat.name from Cat cat
select count(distinct cat.name), count(cat) from Cat cat
--

所以,我就嘗試使用
select distinct c.* from Column c, 在hql中,使用 * 必須要用到別名的
查詢出的結果是 null來的.
在mysql 中,這種寫法是沒有錯的,..然后我再試了一下
select distinct c from Column c , 這樣得出的結果是非null,是正確的.