I am using Hibernate with my Spring MVC project.
Suppose my model has 2 objects, each of which is associated with Oracle tables, respectively, USERS (USERID, NAME)andUSERMONEYDATA (CATEGORY, USERID, AMOUNT)
My users can add, edit and delete lines in USERMONEYDATAwhich belong to them, of course. Now I want to have a view that combines this data.
Using oracle, I did a simple scan to get the total amount for each user and category:
select userid, category, sum(amount)
from USERS a inner join USERMONEYDATA b on a.USERID = b.USERID
group by userid, category
But what is the best way to use it? Should I create a new MODEL object specifically for this view?
Do I need to aggregate directly in Hibernate? But if so, how can I show the results if I do not have a specific POJO object to map it to?
thank