You need to add an alias for the count to your query and then use the addScalar()
method as the default for list()
method in Hibernate seams to be BigInteger
for numeric SQL types. Here is an example:
List<Long> sqlResult = session.createSQLQuery("SELECT column AS num FROM table")
.addScalar("num", StandardBasicTypes.LONG).list();