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.