Joined: Thu May 06, 2010 6:36 pm Posts: 1
|
class Question { long id; // primary key String description; }
class Vote { long id; long question_id; // points to question's id boolean vote; // 0 = no, 1 = yes; }
I have one class per table mapping set up and I am not using hibernate to generate my java classes
My issue is that I want to display the data in the following form:
Description | Total Yes | Total No Do you like Red? | 10 | 2 Do you like blue? | 20 | 1
So my original query looked like:
from Question;
This would select all questions. Now I want to add the count(*) to the query result. I do not want hibernate to return just a generic multi dimensional List of objects. I would like to find a way to "tack on" the count(*) as a dynamic field in the java object so I could use reflection to say getTotalYes() votes. The reason I do not just add a member variable is that the count values are only used for visual display in one part of the app.
Is there a built in way to do this or do I have to either return a generic results set/add a member variable.
I don't like adding the member variable because then I am pushing interface elements down to my data layer and I don't like the generic Lists since I would have to go back and change a lot of code.
Any ideas?
|
|