對於定義標準,我使用下面的代碼塊錯誤獲取的唯一結果數在休眠
Conjunction c1 = Restrictions.conjunction();
c1.add(Restrictions.eq("owner", 123));
c1.add(Restrictions.eq("shared", 'N'));
c1.add(Restrictions.eq("cId", 20));
Conjunction c2 = Restrictions.conjunction();
c2.add(Restrictions.eq("shared", 'Y'));
c2.add(Restrictions.eq("cId", 20));
criteria.add(Restrictions.or(c1, c2));
然後,我想取這個標準的唯一結果。
CriteriaImpl criteriaImpl = (CriteriaImpl) criteria;
Projection originalProjection = criteriaImpl.getProjection();
ResultTransformer originalResultTransformer = criteriaImpl.getResultTransformer();
Object rowCount = criteria.setProjection(Projections.rowCount()).uniqueResult();
int rc = (Integer) rowCount;
但是,代碼在criteria.setProjection(Projections.rowCount()).uniqueResult()
失敗,印刷在服務器日誌這樣下面的錯誤:
信息:迫使在事務完成批量資源清理;忘了關閉ScrollableResults/Iterator?
這走來的例外是:
java.lang.ClassCastException:java.lang.Character中不能轉換爲java.lang.String
任何想法,我我錯了嗎?
也就是說'Info'消息,什麼是例外,這兩個地方? – 2015-03-02 09:58:35
添加到問題中,請檢查。 ClassCastException它是。 – swateek 2015-03-02 10:02:51