Grails

Make binding errors behave more like validation errors

Details

  • Type: Sub-task Sub-task
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Duplicate
  • Affects Version/s: 1.0.3
  • Fix Version/s: 1.1
  • Component/s: None
  • Labels:
    None

Description

An explanation of the current behaviour and why it's not exactly ideal is given here:

http://www.cacoethes.co.uk/blog/index.php?p=38

One possible solution is to use the Hibernate's Session.setReadOnly() method to ensure that changes to a domain instance are not persisted at flush time if there are any binding or validation errors.

Hopefully it would also be possible to call Session.setReadOnly(false) to make the changes persist if, for example, the save() succeeds after any binding errors have been manually rectified. It might be worth making the method available on domain instances directly too.

Activity

Hide
John Allison added a comment -

I've tried to make this simple. Attached is a zip of a grails project with a test illustrating the bug. Calling Domain.hasErrors() causes the database to be updated even if one of the properties has a validation error. This behavior seems rather wrong and still exists in 1.1

Show
John Allison added a comment - I've tried to make this simple. Attached is a zip of a grails project with a test illustrating the bug. Calling Domain.hasErrors() causes the database to be updated even if one of the properties has a validation error. This behavior seems rather wrong and still exists in 1.1
Hide
John Allison added a comment -

The original blog post from bug GRAILS-3163 is long gone.

Here is a grails-user thread related to that blog post:

http://www.nabble.com/The-dangers-of-"obj.properties-%3D-params"-td18065376.html#a18065376

According to that thread, GRAILS-2528 may be related.

Here is another blog post with some other details:

http://stateyourbizness.blogspot.com/2008/05/fun-with-hibernates-flush-mode.html

Show
John Allison added a comment - The original blog post from bug GRAILS-3163 is long gone. Here is a grails-user thread related to that blog post: http://www.nabble.com/The-dangers-of-"obj.properties-%3D-params"-td18065376.html#a18065376 According to that thread, GRAILS-2528 may be related. Here is another blog post with some other details: http://stateyourbizness.blogspot.com/2008/05/fun-with-hibernates-flush-mode.html
Hide
Graeme Rocher added a comment -

This has already been fixed, we set an object to read only if a binding error occurs

Show
Graeme Rocher added a comment - This has already been fixed, we set an object to read only if a binding error occurs

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: