在数据库里测试写下这么一条sql语句。用java hibernate访问,要写成hql,不知道怎么实现,3张表字段是不同的,而且
还有union all,
请高手解决,谢谢!select * from (select * from 
(
    select resourceindexid as resid,
resourcename as resname,
resourcesize as ressize,
firstdetecttime as firsttime,
lastdetecttime as lasttime,
statusid,
resfilepath,
charactervideopath,
1 as typeid,
comments from p2p.resourceindex
         where resourceindexid in (select distinct resourceindexid from resourcename where contains(resourcename,'111 or 222')>0)
union all
select resid,
resname,
ressize,
firsttime,
lasttime,
statusid,
resfilepath,
charactervideopath,
2 as typeid,
comments from bt.torrentres
         where contains(resname,'111 or 222')>0
union all
select webresid as resid,
description as resname,
null as ressize,
firsttime,
lasttime,
statusid,
resfilepath,
charactervideopath,
3 as typeid,
comments from bt.webres
 where  contains(DESCRIPTION,'111 or 222')>0) a where firsttime>to_date('2010-3-15 0:00:00','yyyy-mm-dd hh24:mi:ss')) a where rownum<21