Count number of rows from table using Hibernate

I have a table where records are inserted frequently. And want to show the count of the records and I am using hibernate as an ORM tool.

But I am quite new on this and not understanding how can I get the count from that table.


Below piece of code will help you to find out the count.

return (Number) session.createCriteria("Pojo Name").setProjection(Projections.rowCount()).uniqueResult();

Answer is