users@glassfish.java.net

Re: subquery: select sum(x.fieldA + x.fieldB).... help!

From: Jacek Laskowski <jacek_at_laskowski.net.pl>
Date: Mon, 16 Apr 2007 09:49:09 +0200

On 4/5/07, Witold Szczerba <pljosh.mail_at_gmail.com> wrote:
> Hmm, today we've checked that query using Hibernate EM, and it works.
> Here is entire query:
> SELECT l.id FROM Loan l, in (l.capitalAccount) c
> WHERE l.loanStatus = ?1 AND SUM(c.amountDt) - SUM(c.amountCt) <
> (SELECT ls.capitalDue FROM l.schedule ls
> WHERE ls.dueDate =
> (SELECT max(ls2.dueDate)
> FROM l.schedule ls2 where ls2.dueDate<?2)
> )
...
> Can you tell me, if such a query is not supposed to work under pure/TopLink JPA?
> If so, does it mean I have to change JPA to Hibernate? :(
> I really would like to stay with TopLink...

Hi,

I haven't tried it out myself, but there's nothing I could spot that
would be against JPQL BNF. I think the above query should work fine
with any JPA provider, TopLink including.

Jacek

-- 
Jacek Laskowski
http://www.JacekLaskowski.pl