Hibernate version: Hibernate 2
Name and version of the database you are using: MySQL
Hi there,
When I'm doing the mappings of POJO properties to MySQL columns everything is running smoothly.
With a snippet of code like this I get a list with UserGroup objects:
Code:
Query query = this.hibernate().getHibernateSession().createSQLQuery(
"select {grp.*}, m.first_name " +
"from ch_group {grp}, ch_member m " +
"where m.is_group_admin = 1 and {grp}.group_id = m.group_id ",
"grp",
chawk2.pojo.UserGroup.class);
list = query.list();
Naturally I can access all POJO properties using UserGroup getters.
However, my challenge is retrieving additional values that I've added to SQL SELECT. Typical example is m.firstName above (not a property of UserGroup POJO).
Is there a way to access items in SELECT that are not in POJO and that aren't mapped? I was thinking, it would be convenient if I could add all these other items in SELECT to a Map which I can access via POJO a getter - [something like Map getMap()].
I am just not sure how would I go about implementing this.
If this is not possible, how do you usually handle this?
I can create a new class UserGroupReport with completely new mappings, but I'm thinking there has to be an easier way to deal with this type of problem. Can someone please steer me to the right direction?
The books that I've read are either too complex for a beginner or don't offer what I'm looking for.
Thank You,
Tim