0
from Article as a where communityId=any(select communityId from tblcommunity where district_id=510185)

“tblcommunity”是我数据库中的一个表,我使用的是 Grails 2.2.1,异常消息是:

tblcommunity is not mapped [from com.sccn.article.Article as a where communityId=any(select communityId from tblcommunity where district_id=510185)] 

我想知道如何在 HQL 中没有映射实体类的子查询中使用表名。

4

1 回答 1

0

在本机查询(createNativeQuery()createSQLQuery())中创建:

select communityId from tblcommunity where district_id=510185 

然后将结果用作您的 hql 参数

where communityId in (:yourParamAsArray)

或单个结果:

where communityId = (:yourParam)
于 2013-07-20T17:10:52.713 回答