Grails
  1. Grails
  2. GRAILS-8061

beforeValidate didn't get called in cascade validation

    Details

    • Type: Bug Bug
    • Status: In Progress
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.7
    • Fix Version/s: 2.4
    • Component/s: Persistence
    • Labels:
      None

      Description

      I have two classes: Parent and Child.

      class Parent {
        static hasMany = [children:Child]
      }
      
      class Child {
        static belongsTo = [parent:Parent]
      
        String name
      
        def beforeValidate() {
          name = 'hard coded in beforeValidate'
        }
      }
      

      I use the following code to create a parent instance in ParentController.

      def save = {
        def parentInstance = new Parent(params)
        parentInstance.addToChildren(new Child(name:params.name))
        if (parentInstance.save(flush: true)) {
          ...
        }
        else {
          ...
        }
      }
      

      The child instance will get created with the name passed from HTTP parameter instead of the string hard coded in the beforeValidate() method.

      1. demo.tar.gz
        200 kB
        Kenny Cheang

        Issue Links

          Activity

          Hide
          Aaron Long added a comment -

          I really wish this ticket would get some priority. It makes it very hard to use beforeValidate for anything important.

          Any updates on this ticket? It has several votes but isn't even scheduled at this point. Any chance the Hibernate 4 stuff could open up new avenues?

          Show
          Aaron Long added a comment - I really wish this ticket would get some priority. It makes it very hard to use beforeValidate for anything important. Any updates on this ticket? It has several votes but isn't even scheduled at this point. Any chance the Hibernate 4 stuff could open up new avenues?
          Hide
          Jeff Scott Brown added a comment -

          We are wrapping up 2.3.2 now. I don't have time to work on this immediately myself. If this isn't resolved for 2.3.2 it probably will be for 2.3.3 and definitely for 2.4.

          Show
          Jeff Scott Brown added a comment - We are wrapping up 2.3.2 now. I don't have time to work on this immediately myself. If this isn't resolved for 2.3.2 it probably will be for 2.3.3 and definitely for 2.4.

            People

            • Assignee:
              Jeff Scott Brown
              Reporter:
              Kenny Cheang
            • Votes:
              7 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

              • Created:
                Updated:
                Last Reviewed:

                Development