code: public long countByHql(String secondHalfOfHql, Object[] paramValues, Type[] paramTypes){
      	StringBuilder queryStr = new StringBuilder();
      	queryStr.append("select count(*) from ")
  			.append(this.clazz.getName())
  			.append(" ");
      	if (secondHalfOfHql != null){
      		queryStr.append(secondHalfOfHql);
       	}
      	
          Session session = this.getCurrentSession();
      	Query query = session.createQuery(queryStr.toString());
      	setupQuery(query, paramValues, paramTypes, null, null);
          return ((Number)query.uniqueResult()).longValue();
      }
docs: Get the count of all records in database
  @param secondHalfOfHql	parts after "from &lt;class_name&gt; "
  @param paramValues
  @param paramTypes
  @return the count