2011-01-22 36 views
3

下面的查詢應該選擇不在excludedOrgs所有組織:「NOT IN」 與HQL和Grails

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

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

我正在使用Grails 1.3.6。

我的查詢出了什麼問題?

回答

8

都應該工作(如命名和位置PARAMS被允許)

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

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