【问题标题】:"NOT IN" with HQL and Grails使用 HQL 和 Grails 的“NOT IN”
【发布时间】:2011-06-13 16:57:22
【问题描述】:

以下查询应选择不在excludedOrgs 中的所有组织:

Organisation.findAll("from Organisation o where o not in elements(?)", 
    [excludedOrgs])

我得到的只是一个 org.springframework.orm.hibernate3.HibernateQueryException 告诉我:expecting IDENT, found '?'

我正在使用 Grails 1.3.6。

我的查询有什么问题?

【问题讨论】:

    标签: java hibernate orm grails hql


    【解决方案1】:

    两者都应该工作(允许命名和位置参数)

    Organisation.findAll("from Organisation o where o not in (?)", [excludedOrgs])
    
    Organisation.findAll("from Organisation o where o not in (:excludedOrgs)", ["excludedOrgs":excludedOrgs])
    

    【讨论】:

      猜你喜欢
      • 2016-04-03
      • 2012-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-17
      • 2016-08-21
      • 1970-01-01
      • 2012-01-24
      相关资源
      最近更新 更多