Is there a 'not in' equivalent in GORM?

前端 未结 5 962
我寻月下人不归
我寻月下人不归 2021-02-15 10:21

Is this possible to convert in createCriteria()?

SELECT * FROM node WHERE (node.type = \'act\' AND nid NOT IN (SELECT nid FROM snbr_act_community)) LIMIT 10
         


        
5条回答
  •  情深已故
    2021-02-15 10:59

    not tried it myself but looking at the Grails doc and hibernate api you create nodes on this builder map with the static methods found in the Restrictions class of the Hibernate Criteria API 1. So something like

     def c = VolunteerOpportunity.createCriteria()
    def matchingActs = c.list {
        node {
            not(in('propertyName', ['val1','val2']))
        }
        maxResults(10)
    }
    

    Since you chain the in method (that returns a Criterion) with the not method (that takes a Criterion as argument and returns a negated version)

提交回复
热议问题