-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Can I access Query metadata?
PostPosted: Mon Oct 15, 2007 10:56 pm 
Newbie

Joined: Mon Aug 27, 2007 11:11 pm
Posts: 8
Location: Brisbane
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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.