0
請幫我這個。DetachedCriteria - 如何將分離標準結果轉換爲整數?
我使用分離標準來獲得客戶總數。
在我CustomerDaoImpl:
@Override
public int getCustomerSize() {
DetachedCriteria dc = getDetachedCriteria();
dc.setProjection(Projections.count("customerId"));
// I need to return only the count result.
return 0;
}
通常我做的是我得到的結果,存儲在一個集合中,並使用collection.size
。我不認爲它的高效率,因爲我必須獲取不必要的數據才能獲得count
。請幫忙。