Hello to all of you.
I am quite new to hibernate, but i am really exited about the functionallity, and the easy usage.
However i am creating an application where i have to perform a subselect in a from clause.
After searching the hibernate reference i found out, that hibernate does not support subselects in from clause.
Quote:
Note that HQL subqueries can occur only in the select or where clauses.
My question: is there any workaround to get such a select?
I am providing an example:
I Have a table which stores dates for member. But for a statistic, i am only interessted in the in the amount of dates per month(and year). But due to the fact that one member hase more entries in the table, i am only interrested in the latest date per member.
In normal sql i would wrote this (pseudo sql)
Code:
SELECT Count(member), Month(date), Year(date)
FROM (
SELECT user as member, max(time) as date
FROM table
WHERE ....
GROUP BY user
) AS vtable
GROUP BY Month(date), Year(date)
ORDER BY ...
This code is working in sql. I testet it directly in the database. Unfortunately i cant think of another way to get this statement provided.
I can do the Subselect and create a new object, where i count the members in the java code. But the application provices about 4000 members with each 50 relevant entries. And i dont like to select 4000 rows from the database, just to work with about 30 sets of data.
Is there any posibillity?
Or only the words of Chris Wilson:
Quote:
I just haven't needed it yet, so I haven't had a reason to implement it.
Thank you for your help