Grails 在HQL中没有映射实体类的子查询中使用tablename
“tblcommunity”是我数据库中的一个表,我使用的是Grails 2.2.1,异常消息是:Grails 在HQL中没有映射实体类的子查询中使用tablename,grails,hql,Grails,Hql,“tblcommunity”是我数据库中的一个表,我使用的是Grails 2.2.1,异常消息是: from Article as a where communityId=any(select communityId from tblcommunity where district_id=510185) 我想知道如何在HQL中没有映射实体类的子查询中使用tablename。在本机查询中创建(createNativeQuery()或createSQLQuery()): 然后将结果用作hql参数
from Article as a where communityId=any(select communityId from tblcommunity where district_id=510185)
我想知道如何在HQL中没有映射实体类的子查询中使用tablename。在本机查询中创建(createNativeQuery()
或createSQLQuery()
):
然后将结果用作hql参数
select communityId from tblcommunity where district_id=510185
或对于单个结果:
where communityId in (:yourParamAsArray)
如果不想映射该表,则需要使用直接sql。
where communityId in (:yourParamAsArray)
where communityId = (:yourParam)