Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > generic count report for JPQL query

Reply
Thread Tools

generic count report for JPQL query

 
 
Giovanni Azua
Guest
Posts: n/a
 
      05-31-2009
hello,

Suppose I'm given a valid JPQL query and I would like to find out how many
rows it would return if executed but without actually executing it.

Example input JPQL: select p from Person p where p.name like "Giov%"

and I would like to generate something like (this one does not work):

select count(e) from (<the input query here>) e
select count(e) from (select p from Person p where p.name = "Giovanni") e

I have tried several JPQL possibilities without success. The context of this
problem is while implementing the Value List Handler Pattern, the lazy
strategy would not execute the actual query immediately but needs to know
what the total number of records is so the iterator state can be consistent.

The other possibility I was considering was to accept not only the query as
input but also the corresponding count reporting query too. However, this is
somewhat redundant and error-prone because the client could in theory hand
in a wrong reporting query that would not match the original query.

I think this kind of query is ANSI SQL therefore supported by all Database
vendors, hence using native queries would be cool ... but it feels wrong
stepping aside from JPQL

TIA,
regards,
Giovanni


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Count = Count + 1 Using only std_logic_1164 Doubt efelnavarro09 VHDL 2 01-26-2011 03:49 AM
generic interfaces with generic methods Murat Tasan Java 1 02-03-2009 12:17 PM
How compare the same entity in JPQL ? marek Java 1 03-12-2008 01:32 AM
Count(*) in a Subquery with multiple tables: How does SQL determine which table to generate the Count() from? Kaimuri MCSD 3 12-29-2004 06:38 PM
I am adding a new row to the datagrid dynamically but if i use the Count property of Item it is not showing the count of the new rows being added Praveen Balanagendra via .NET 247 ASP .Net 2 06-06-2004 07:16 AM



Advertisments