-->
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: mapping named hqlquery over multi-tables to one entity class
PostPosted: Wed Feb 22, 2006 9:15 am 
Newbie

Joined: Fri Oct 28, 2005 10:32 pm
Posts: 13
hello,
I want to make a mapping from a named hql over multi-talbes to one single entity class,some kind like create a db-view which I can pass into parameters.
below is my named hql:

Code:
<sql-query name="channelOfUser">
   <return alias="channel" class="com.mobileInformation.bo.ChannelOfUser"/>
   
      SELECT channel.rss_channel_id AS {channel.rssChannelId},
      channel.channel_title AS {channel.channelTitle},
      channel.channel_link AS {channel.channelLink},
      channel.channel_description AS {channel.channelDescription},
      channel.src_link AS {channel.srcLink},
      channel.channel_icon_url AS {channel.channelIconUrl},
      
      (from com.mobileInformation.bo.ChannelReference channelReference) AS{channel.channelReference},
      
      (from com.mobileInformation.bo.RssArticle article) AS {channel.rssArticles},
      
      FROM rss_channel channel,channel_reference channelReference,
      rss_article articles,rss_reference rssReference
      where channelReference.user_id=:userId
      and channelReference.rss_channel_id=:channelId
      and articles.rss_channel_id=:channelId
      and rssReference.user_id=:userId
      and rssReference.rss_channel_id=:channelId
      and rssReference.is_read=0;
      
</sql-query>


and here is my entity class:
Code:
public class ChannelOfUser implements Serializable {

   private static final long serialVersionUID = 1L;

   /** identifier field */
   private String rssChannelId;

   /** nullable persistent field */
   private String channelTitle;

   /** html url of the channel */
   private String channelLink;

   /** nullable persistent field */
   private String channelDescription;

   /** xml(rss) url of the channel */
   private String srcLink;

   /** nullable persistent field */
   private String channelIconUrl;

   /** persistent field */
   private Set rssArticles;
.....
}

which cannot be associated with one single table.

when I use this named hql,errors occur indicating that the class
"ChannelOfUser" is not mapped.but I donot know how
to write this mapping file,one entity class VS multi tables,allowing
passing parameters into the query.


Top
 Profile  
 
 Post subject: hql
PostPosted: Wed Feb 22, 2006 6:26 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
HQL does not operate in terms of tables.

I suspect that you could better of just creating a view and map your class to the view. But you may look here too:
http://www.hibernate.org/hib_docs/v3/re ... strategies

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


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.