Hibernate version: 3
I want to be able to have a user dynamically specify a query and when I execute the query, I want to be able to look at the query and work out the columns that are being returned and the types of the columns.
From looking at the Query class, it seems I only have access to 3 methods to get metadata about the Query; getReturnAliases(), getNamedParameters() and getReturnTypes(). I don't think this is enough information.
For example, I have the following mapping...
Code:
<class entity-name="FmcInaccReasonCodes" table="FMC_INACC_REASON_CODES" dynamic-insert="true" dynamic-update="true">
<composite-id>
<key-property name="inspectionType" column="INSPECTION_TYPE" type="string" length="2"/>
<key-property name="keyValue" column="KEY_VALUE" type="integer"/>
</composite-id>
<property name="seqNo" column="SEQ_NO" type="integer"/>
<property name="msf010Code" column="MSF010_CODE" type="au.com.cyberavenue.majalin.OracleCHAR" length="18"/>
</class>
If a user wants to execute the query "select inspectionType from FmcInaccReasonCodes", I will create a Query object like so...
Code:
String selectQueryStatement = "select inspectionType from FmcInaccReasonCodes"; // passed in by the user
Query selectQuery = dynamicSession.createQuery( selectQueryStatement );
Now I want to look at the query and work out the name(s) of the values being returned. I can get the type of the column by doing...
Code:
Type[] returnTypes = seelctQuery.getReturnTypes();
and this will return a String but I also want to know that the name of the value I'm getting is "inspectionType". How can I look at query metadata to get this information?