【发布时间】:2019-07-06 00:27:45
【问题描述】:
grailsVersion=3.2.9, gormVersion=6.0.10
假设我们有两个 grails 域:
class A {
int id
B b
}
class B {
int id
}
现在,如果我的代码中有一些 B 的 ID(假设我在枚举中有该 ID),则使用 GORM 动态查找器通过 B 的 ID 获取 A 的实例是唯一的方法如下:
A.findByB(B.get(bId))
这确实会导致额外的查询来获取B 实例,这并不理想。
那么有什么办法,也许是一些 Grails/GORM 插件,添加对以下内容的支持:
A.findByBId(bId)
【问题讨论】:
标签: java hibernate grails relational-database grails-orm