Grails GORM hasMany association inconsistent with MongoDB, 当尝试获取子记录时,它有时获取记录有时不获取
Grails GORM hasMany association inconsistent with MongoDB, When try to fetch child Records,it fetches the record sometimes and doesn't fetch sometimes
下面是域 class Author
,它与 Book
具有一对多关联。尝试获取作者时,有时会获取 Book
域对象的关联集合,有时会获取 returns 空值。关于为什么它不一致有什么想法吗?
class Author {
static mapWith = "mongo"
String name
static hasMany = [books: Book]
}
_author.gson
model {
Author author
}
json g.render(author]) {
books g.render(author.books)
}
环境详情:
grailsVersion=3.3.5
gormVersion=6.1.8.RELEASE
我们正在使用 GORM 多租户并使用 MongoDB 数据库。
我已经切换到子文档模型,现在可以使用了。这是域模型代码。
class Author {
static mapWith = "mongo"
String name
List<Books> book
static embedded = ['book']
}
下面是域 class Author
,它与 Book
具有一对多关联。尝试获取作者时,有时会获取 Book
域对象的关联集合,有时会获取 returns 空值。关于为什么它不一致有什么想法吗?
class Author {
static mapWith = "mongo"
String name
static hasMany = [books: Book]
}
_author.gson
model {
Author author
}
json g.render(author]) {
books g.render(author.books)
}
环境详情:
grailsVersion=3.3.5
gormVersion=6.1.8.RELEASE
我们正在使用 GORM 多租户并使用 MongoDB 数据库。
我已经切换到子文档模型,现在可以使用了。这是域模型代码。
class Author {
static mapWith = "mongo"
String name
List<Books> book
static embedded = ['book']
}