Grails

GORM save, merge and delete should have option to use flush: true and failOnError: true by default

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.2-M3
  • Component/s: Persistence
  • Labels:
    None

Description

Should be great to have the option to set something like

grails.gorm.flush = true
grails.gorm.failOnError = true

in Config.groovy to use the by default for calls to save, merge and delete.

My code now contains a lot of boilerplate like save(flush: true) as I'm doing this everywhere. Even this is the default in scaffolding.
I even would argue that grails.gorm.flush should be set to true by default then in Config.groovy.

Issue Links

Activity

Hide
Ted Naleid added a comment -

I would definitely use the failOnError = true setting if it were available.

Show
Ted Naleid added a comment - I would definitely use the failOnError = true setting if it were available.
Hide
Marcel Overdijk added a comment - - edited

Yes me to! The problem now is that I sometimes forget it...
That's why it would be good to be able to override the defaults.

Show
Marcel Overdijk added a comment - - edited Yes me to! The problem now is that I sometimes forget it... That's why it would be good to be able to override the defaults.
Hide
Jeff Brown added a comment -

FYI...

GORM already supports grails.gorm.save.failOnError = true. See GRAILS-4343 and/or http://grails.org/doc/latest/ref/Domain%20Classes/save.html.

Show
Jeff Brown added a comment - FYI... GORM already supports grails.gorm.save.failOnError = true. See GRAILS-4343 and/or http://grails.org/doc/latest/ref/Domain%20Classes/save.html.
Hide
Ted Naleid added a comment -

Right but you have to do it every time you call save. What we want is something in Config.groovy where you can set the system wide default for save to be failOnError = true. (unless I'm missing something)

Show
Ted Naleid added a comment - Right but you have to do it every time you call save. What we want is something in Config.groovy where you can set the system wide default for save to be failOnError = true. (unless I'm missing something)
Hide
Ted Naleid added a comment -

Ah yep, sorry, I'm missing something. Scratch that.

Thanks Jeff!

Show
Ted Naleid added a comment - Ah yep, sorry, I'm missing something. Scratch that. Thanks Jeff!
Hide
Marcel Overdijk added a comment -

So only something like grails.gorm.flush = true is needed then

Thanks Jeff

Show
Marcel Overdijk added a comment - So only something like grails.gorm.flush = true is needed then Thanks Jeff
Hide
Jeff Brown added a comment -

For flush=true, is there any reason to have different properties for save, delete and merge?

Show
Jeff Brown added a comment - For flush=true, is there any reason to have different properties for save, delete and merge?
Hide
Marcel Overdijk added a comment -

I don't think so.
You are considering creating 3 properties?
Perhaps this the most dynamic option but I wonder if one would different values...

Show
Marcel Overdijk added a comment - I don't think so. You are considering creating 3 properties? Perhaps this the most dynamic option but I wonder if one would different values...
Hide
Jeff Brown added a comment -

The grails.gorm.autoFlush property may now be set to true in Config.groovy. This property effects the save(), delete() and merge() methods on domain classes.

Show
Jeff Brown added a comment - The grails.gorm.autoFlush property may now be set to true in Config.groovy. This property effects the save(), delete() and merge() methods on domain classes.

People

Vote (7)
Watch (7)

Dates

  • Created:
    Updated:
    Resolved: