1
我是新来的Grails,我有一些问题,如下所述。Grails:检索所有最新的儿童记录
我有2个域类:父和子。我将数组数组存储到数据库中。
父类是:
class Parent{
static hasMany = [child: Child]
}
子类:
class Child {
String time
String record
String value
static belongsTo= [parent: Parent]
static constraints = {
time(blank: false)
record(blank: false)
belongsTo(blank: false)
}
}
现在,我的要求是:
我需要检索包含在数据库中的多行,孩子的最新记录与唯一的父母身份证。 例如:家长的最新ID是7. 子表包含父亲ID为7的近10条记录。我想通过引用父母ID(7)检索所有这10条记录。
请帮忙写一段代码/查询。
感谢您的帮助。 – user3719407 2015-01-12 13:42:06
@ user3719407;)您的欢迎 – Lrrr 2015-01-12 14:32:49