For older versions of Hibernate (<5.2):
Assuming the class name is Book:
return (Number) session.createCriteria("Book")
.setProjection(Projections.rowCount())
.uniqueResult();
It is at least a Number
, most likely a Long
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…