gpt4 book ai didi

hibernate - Grails-是级联事务

转载 作者:行者123 更新时间:2023-12-02 14:01:34 26 4
gpt4 key购买 nike

在Grails中,事务内是否会发生级联?

以下是Grails文档中的一个示例来演示:

给定以下类别:

class Airport {
String name
static hasMany = [flights: Flight]
}

class Flight {
String number
static belongsTo = [airport: Airport]
}

If I now create an Airport and add some Flights to it I can save the Airport and have the updates cascaded down to each flight, hence saving the whole object graph:


new Airport(name: "Gatwick")
.addToFlights(new Flight(number: "BA3430"))
.addToFlights(new Flight(number: "EZ0938"))
.save()

即使代码未包装在任何事务中,Grails / Hibernate能否保证此操作是原子操作?

来源取自示例 here

最佳答案

不,如果不使用事务,就无法保证原子操作(例如通过GORM或Hibernate)的原子操作。

关于hibernate - Grails-是级联事务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27432005/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com