Hibernate version: 3.0
Hi,
I'd like to know if there's a way to access the property name of the returned results for an hql query. For example, for this query : "select client.firstName, client.lastName from Client client", i'd like to obtain metadata information that would give me access to the two property names : "firstName" and "lastName".
I found a way to access the return types ( Query.getReturnTypes() ), but not the return names.
On a JDBC ResultSet, the getResultSetMetaData() returned a structure that allowed me to get the column names. An equivalent structure could be available in an hql query via a getQueryMetadata() method.
This feature would be quite useful for the following purposes :
- Tools like the Hibernate Console could show the returned property names for an hql query.
- We could access the returned values of an hql query by name rather than by position in an Object array. For a complex select with many returned properties, this would be really useful.
- I use a generic tool to serialize the result of a query in an xml structure. I would like to use the name of the properties as the xml element names.
Thank you
|