-->
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.  [ 2 posts ] 
Author Message
 Post subject: Query in hbm.xml
PostPosted: Wed Dec 20, 2006 7:00 am 
Newbie

Joined: Wed Dec 20, 2006 6:45 am
Posts: 3
Hi,

I am a newbie. I write my SQl query in hbm.xml and the path of the hbm is defined in hibernate.cfg.xml. But the issue is, I have to mention all the column names even if I wish to use 2 of them.

sample of query in hbm.xml
Suppose there are only 2 columns in the table:

<sql-query name="fetchparameters">
<return alias="databasefile" class="src.DatabaseFile"/>
SELECT {databasefile}.ROLEID AS {databasefile.ROLEID }
,{databasefile}.ROLENAME AS {databasefile.ROLENAME}
FROM DatabaseFile{databasefile}
WHERE {databasefile}.ROLEID LIKE :ROLEID AND
{databasefile}.ROLENAME LIKE :ROLENAME
</sql-query>

DatabaseFile is a java file where all the getters/setters are present.

Now, if I want only 1 column, it gives me an error:


org.hibernate.exception.SQLGrammarException: could not execute query
Caused by: java.sql.SQLException: An undefined column name was detected.



Kindly guide me...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Dec 20, 2006 11:09 am 
Expert
Expert

Joined: Fri Aug 19, 2005 2:11 pm
Posts: 628
Location: Cincinnati
Code:
<sql-query name="queryName">
      <return-scalar column="status" type="string"/>
         <![CDATA[
         SELECT status from my_table
]]>
</sql-query>

_________________
Chris

If you were at work doing this voluntarily, imagine what you'd want to see to answer a question.


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

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.