Try:
java.math.BigInteger rc = (java.math.BigInteger)hSession.createSQLQuery(
"SELECT COUNT(DISTINCT ac_cc_id) as cnt"+
" FROM attorney_case ac "+
" JOIN consumer_case_category_xref cccx ON ac.ac_cc_id=cccx.cccx_cc_id "+
" JOIN category_to_users catmap ON cccx.cccx_cat_id=catmap.catmap_cat_id AND catmap.catmap_catsup_id=? "+
" where ac.ac_usr_id=? and ac.ac_hide=0")
.addScalar("cnt",Hibernate.BIG_INTEGER)
.setLong( 0, superCat.getId() )
.setLong( 1, this.getId() )
.setCacheable(true)
.uniqueResult();
|