Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

EJB-QL count query????  RSS feed

 
Johann Dobbins
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
help please?
 
Reza Rahman
author
Ranch Hand
Posts: 580
5
  • Mark post as helpful
  • send pies
  • 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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!