This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes getting count of HQL query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "getting count of HQL query" Watch "getting count of HQL query" New topic
Author

getting count of HQL query

Jj Dire
Greenhorn

Joined: Jan 27, 2009
Posts: 3
I'm trying to do pagination so I need to know the count but it seems such a difficult task to find the count of a query which deferences another table. The query is



Patient POJO is


Here's my attempt at finding the count of this but no matter what it doesn't like the patient_insurance dereferning. I tried select count(*) way and this way and neither seems to work



I am totally lost and wondering what's an easy way just to get a count of a relatively simple query.

When doing select count(*) of the above query I get the "the owner fetched association was not present in the select list" error.

Thanks in advance.
Jj Dire
Greenhorn

Joined: Jan 27, 2009
Posts: 3
found solution by using createAlias
Javid Jamae
Author
Ranch Hand

Joined: May 14, 2008
Posts: 198
You should be able to do this with a "select count" query. What are you trying to get a count of exactly? Show the select query and the table structure (DDL).


Author: JBoss in Action, javidjamae.com, @javidjamae on Twitter
Jj Dire
Greenhorn

Joined: Jan 27, 2009
Posts: 3
the query is shown in my original post. If I just add select count(*) to the first query shown above, hibernate will complain. I've managed to do them all using projections.
every member is a string except date and id (date and integer).
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Hurric hurric" please check your private messages.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting count of HQL query
 
Similar Threads
Using Named Queries
ClassCastException
Question with generics Please help
Java Collections
Problem - how to ask for date of birth