开发者

Is Grails supposed to ignore the flush mode in integration tests?

开发者 https://www.devze.com 2023-03-09 15:15 出处:网络
I\'m working on a Grails (transactional) service which builds a complex domain structure and persists it. The logic works by identifying a previous structure, then creating a new structure and then --

I'm working on a Grails (transactional) service which builds a complex domain structure and persists it. The logic works by identifying a previous structure, then creating a new structure and then -- if it passes validation -- removing any old structure and persisting the new one. Grails flush modes are getting in the way, because the validation logic does queries, which in AUTO mode persists parts of the domain structure before it is complete.

I have set in DataSource.groovy:

hibernate {
    flush.mode = "commit"
}

because I need (I think) to turn off the AUTO handling which flushes on query. Without this, parts of my new structure are being written incrementally during the validation process, which causes Hib开发者_如何学编程ernate to throw hideous integrity errors.

During my integration test -- despite the setting in DataSource.groovy -- the flush mode is still logged as AUTO. Is there a good reason why Grails shouldn't respect my setting?


The default cascade behaviour is save-update for one-to-many relationship. Try cascade none

static mapping = {
    foos cascade:'none'
}
0

精彩评论

暂无评论...
验证码 换一张
取 消