【问题标题】:Criteria to get all Person's, who doesnt own a Ford car获得所有没有福特汽车的人的标准
【发布时间】:2015-01-22 10:01:33
【问题描述】:

我有一个域类Person,如下

class Person {
   static hasMany=[cars:Car]
}

现在,我想获取所有Person没有“福特”汽车的人。以下标准的问题在于,它用两辆汽车获取“人”,其中一辆是“福特”。

List promotions = Person.createCriteria().list(  ) {
    cars {
        ne(‘name’, ‘Ford’)
    }
}

【问题讨论】:

标签: grails grails-orm hibernate-criteria


【解决方案1】:
List promotions = Person.createCriteria().list(  ) {       
 sqlRestriction " id not in (select person_id from car where 'Ford' = name );"
}

【讨论】:

    猜你喜欢
    • 2019-10-31
    • 2011-02-14
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多