-->
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.  [ 4 posts ] 
Author Message
 Post subject: Help with the named query!!
PostPosted: Wed Jan 19, 2005 4:35 pm 
Newbie

Joined: Wed Jan 19, 2005 4:21 pm
Posts: 2
I defined a named query in my mapping file,

<sql-query name="getFlexibleAttributes">
<return alias="attribute" class="com.xxx.app.dal.AttributeTO"/>
<![CDATA[SELECT fd.LABEL as {attribute.attributeName}, fn.ATTRIBUTE_VALUE as
{attribute.attributeValue}
FROM TABLE_PART_NUM pn, TABLE_FA_PART_NUM fn, TABLE_FLEX_DEFN fd
WHERE fn.FA_PART_NUM2PART_NUM = pn.OBJID and
fd.ATTRIBUTE_NAME = fn.ATTRIBUTE_NAME and
pn.PART_NUMBER = :partNumber]]>
</sql-query>

What I'm trying to do is to pull data from three different tables into object AttributeTO. There is no physical table for the object AttributeTO. Is it doable? If the answer is yes, whatelse do I have to define in the mapping file?


Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 8:45 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, this is not possible. sql-queries can only return Hibernate mapped classes.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 11:34 pm 
Newbie

Joined: Wed Jan 19, 2005 11:20 pm
Posts: 2
Is it possible to select data from 2 tables into 1 mapped class? To be more specific a class called JobClassification with variables jc_id and jc_name and a table job_classification with fields jc_id, jc_name and jc_code where jc_code is a foreign key for a job_classification_code table with a PK field jcc_id and a further field jcc_product. Ultimately, i want to populate the JobClassification class with the jc_id (from job_classification) and jcc_product (from job_classification_code) concatenated with the jc_name (from job_classification) field.

I can run such a sql query from an Oracle client:

select jc_id, jcc_code || ' || ' || jc_name as jc_name from job_classificat
ion inner join job_classification_code on jc_code = jcc_id;

What about hibernate?

Paul


Top
 Profile  
 
 Post subject: Help with the named query!!
PostPosted: Thu Jan 20, 2005 10:04 am 
Newbie

Joined: Wed Jan 19, 2005 4:21 pm
Posts: 2
Doese Hibernate mapped classes have to map to a physical table?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.