• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

EJB-QL count query????

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do I preform a query that returns the number of rows that meet a condition?

I assume its something like:



but i realize this is very wrong. help please?

thanks
 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Johann Dobbins wrote:How do I preform a query that returns the number of rows that meet a condition?

I assume its something like:



but i realize this is very wrong. help please?

thanks



to clarify, i don't want to simply do:



because the select query has a few join fetches and would be quite expensive if there are more than a certain number of records. so, i would like to first count the number of records and only populate a result set if the number is small enough.

thank you
 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
help please?
 
author
Posts: 580
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Johann,

Take a look at the JPQL 'NEW' operator. That would really be the only way to do this. Otherwise, you could look into native queries.

Hope it helps,
Reza
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic