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)]
我想知道如何在子查询中使用tablename,它在HQL中没有映射的实体类。
答案 0 :(得分:0)
在原生查询中创建(createNativeQuery()
或createSQLQuery()
):
select communityId from tblcommunity where district_id=510185
然后将结果用作hql param
where communityId in (:yourParamAsArray)
或单个结果:
where communityId = (:yourParam)