NOT IN with HQL and Grails

The following query should select all organizations that are not located in excludedOrgs:

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

All I get is org.springframework.orm.hibernate3.HibernateQueryException telling me: expecting IDENT, found '?'

I am using Grails 1.3.6.

What happened to my request?

+3
source share
1 answer

both should work (since named and positional parameters are allowed)

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

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

Source: https://habr.com/ru/post/1787143/


All Articles