2011-01-06 17 views
5

Aşağıdaki kodHazırda Bekletme ile Projections.countDistinct beklenmedik sonuç üretir

 
Criteria criteria = this.getCriteriaForClass(DeviceListItem.class); 
Projection rowCountProjection = Projections.countDistinct("color"); 
criteria.setProjection(rowCountProjection); 
int rowCount = ((Long) criteria.uniqueResult()).intValue(); 
return rowCount; 

var. Sorun,

 
Projections.countDistinct("color"); 

,

 
Projections.count("color"); 

ile aynı sayıda veriyi döndürür. Kriterler nesnesini SQL'e dönüştürdüğümde, Xberxate tarafından üretilen SQL'in

 
select count(this_.COLOR) as y0_ from DEVICESLIST_VIEW this_ where 1=1 

olduğunu

 
select count(distinct this_.COLOR) as y0_ from DEVICESLIST_VIEW this_ where 1=1 

olduğunu görüyorum. Neden beklendiği gibi çalışmıyor ve bazı çare? Maalesef bu durumda HQL'yi kullanma seçeneğim yok.

cevap

İlgili konular