【问题标题】:How to query 3 tables in Grails Gorm如何在 Grails Gorm 中查询 3 个表
【发布时间】:2020-07-23 00:43:05
【问题描述】:

我是 grails 框架的新手,如何查询它们之间有关联的 3 个表

    Class A{
    static hasMany = [b:B]
    }

    enter code here

    class B{
    long aId // Id of table A 
    }

    class c{
    B b //B reference
    }

SQL查询:select * from C where b_id in (select id from B where a_id='10'_)

Any help will be appreciated.

【问题讨论】:

标签: grails groovy grails-orm criteria projection


【解决方案1】:

直截了当

def list = C.withCriteria{
  b{
    eq 'aId', '10'
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-03
    • 2017-03-19
    • 1970-01-01
    • 2013-03-23
    相关资源
    最近更新 更多