-1

I have a database named branchMonthlyUsageStatsId, in this table I have a field named brsType, this field contains a string named cnmt or chln. I want to get the total number of rows having cnmt in them, I want to do it via hibernate. Please help me out.

  • 3
    We don't really like to provide from scratch solutions. Show us something you tried, like your code, and ask a question about why it doesn't behave as you expected. – moffeltje Apr 21 '15 at 09:02
  • I just want that query, I am stuck at this point. – Navneet Srivastava Apr 21 '15 at 09:06
  • 3
    If you're stuck that means you have tried everything you could think about, so there is something you could show us. Or am I wrong? – moffeltje Apr 21 '15 at 09:08

2 Answers2

1

Asking for answer from scratch is highly discouraged in Stackoverflow. At least Show what you have tried. Answer can't be given on the basic of mere assumptions!

Though to help you out you can use Criteria

Criteria criteria = currentSession().createCriteria(type);
criteria.setProjection(Projections.rowCount());
criteria.uniqueResult();
Ankur Anand
  • 3,873
  • 2
  • 23
  • 44
0

I think you should write your question with more detail. As far as I understand, you can use the list that you get from restriction.

// Your restrictions here....

List<aClassofYours> list = criteria.list();
int numberOfRows = list.size();