Groovy的GORM与构建工具:Gant和Ant的深入解析
1. GORM的基础操作与特性
1.1 关联操作
在处理关联关系时,我们可以将多个艺术家添加到歌曲中,也可以将歌曲添加到多个艺术家名下。只需保存作为关系所有者的艺术家对象,所有关联信息都会被保留。以下是示例输出:
Jimmy Page performs
Killing the Blues
Rich Woman
Alison Krauss performs
Killing the Blues
Rich Woman
Rich Woman performed by
Jimmy Page
Alison Krauss
Killing the Blues performed by
Jimmy Page
Alison Krauss
1.2 组合(Composition)
组合用于将子对象的字段嵌入到其父对象的表中,而不是为每个业务对象创建单独的表。例如,在处理客户信息时,我们可以将地址和身份信息嵌入到客户表中。示例代码如下:
class Customer {
String firstName
String lastName
Address billing
Address shipping
Identity ident
static embedded = ['billing','shipping','ident']
}
c
Groovy GORM与构建工具深入解析
超级会员免费看
订阅专栏 解锁全文
81

被折叠的 条评论
为什么被折叠?



