I have a problem with JPA QL and hope that some JPA QL professionals can quickly give me the answer. :-)
In SQL I am doing this:
SELECT MONTH(x) y, YEAR(x) m, COUNT(DISTINCT d) FROM t GROUP BY y, m
This obviously is providing the number of distinct rows for each month. As you can see, the month itself is not a standalone field. Month and Year are extracted from the TIMESTAMP field x. The MONTH and YEAR functions are vendor specific SQL extensions, but certainly could be easily replaced by simple math.
Since we are an ISV, our Java EE application must not use any vendor specific SQL (actually if any possible it should not use SQL at all but always usw JPA QL).
We see that a possible solution is using a native query and do the calculations in ANSI SQL. But it would be much smarter to do JPA QL instead of SQL. Unfortunately in JPA QL we can neither do a calculation in the SELECT clause, nor can we group by the result of such a computation.
So what is the JPA way to solve this?
Thanks
Markus
QUIPSY QUALITY GmbH & Co. KG
Ein Unternehmen der MES-Gruppe
Stuttgarter Strasse 23
D-75179 Pforzheim
Tel: 07231-9189-52
Fax: 07231-9189-59
www.quipsy.de
karg_at_quipsy.de
Registergericht Mannheim HRA 701214
Gesch�ftsf�hrer: Nils Schroeder
Diese E-Mail enth�lt pers�nliche, vertrauliche und vor Weitergabe gesch�tzte Informationen und ist ausschlie�lich f�r den vorgesehenen o.g. Empf�nger (Adressaten) bestimmt. Falls Sie diese E-Mail versehentlich erhalten haben und nicht der vorgesehene Empf�nger sind, bitten wir Sie, die E-Mail und deren Anh�nge nicht aufzubewahren, nicht zu vervielf�ltigen, nicht zu nutzen und nicht weiterzugeben. Bitte informieren Sie uns als Absender �ber diesen Zustellungsfehler und l�schen Sie die E-Mail.
attached mail follows:
Remove Sybase 8
Add Sybase 11