cweston
cweston

Reputation: 11637

Grails - are cascades transactional

In Grails, do cascades happen within a transaction?

Heres an example from the Grails documentation to demonstrate:

Given the following classes:

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()

Does Grails/Hibernate guarantee this operation to be atomic, even if the code is not wrapped in any transaction?

Source taken from the example found here

Upvotes: 2

Views: 72

Answers (1)

Joshua Moore
Joshua Moore

Reputation: 24776

No, without using transactions there is no guarantee of atomic operations such as that through GORM or Hibernate.

Upvotes: 2

Related Questions