These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: count() in named query
PostPosted: Wed May 11, 2005 6:32 am 
Newbie

Joined: Mon May 09, 2005 5:50 am
Posts: 6
Hi,

I have classes as follows;

Code:
Class Fax {
Integer faxId
String faxNumber
Document document
}


Class Document {
Integer documentId
String documentType
String documentName
Date createdTime
}

Can anyone pls give me a named query to find the total number of Faxes. Also I do not know to read the result in this case. Anyone help pls.

Thx,
Vraj


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 6:47 am 
Beginner
Beginner

Joined: Fri Mar 11, 2005 7:52 am
Posts: 34
In the Fax or Document Dao:

Code:
  public Integer getFaxCount()
  {
     Session lSession = HibernateUtil.getSession();
     Integer lFaxCount = (Integer)lSession.createQuery("select count(*) from Fax").uniqueResult();
     return lFaxCount ;
  }


Top
 Profile  
 
 Post subject:
PostPosted: Wed May 11, 2005 7:30 am 
Newbie

Joined: Mon May 09, 2005 5:50 am
Posts: 6
Thanks that worked..!!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.