Grails
  1. Grails
  2. GRAILS-8972

Domain constructor taking map of values fails to create associations and lists

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 2.0.2
    • Fix Version/s: 2.0.3
    • Component/s: Persistence
    • Labels:
      None
    • Environment:
      java 1.6 running amazon aws stock beanstalk config, 64bit m1.small instance.

      Description

      I have domain objects in Grails 2.0.1 that are created and saved with the following syntax:

      // nickname is a string
      def acct = session.get('account')
      def site = new Site(account: acct, nickname: nickname, subItems: [])

      in grails 2.0.2 the following has become broken...
      In the site object... subItems list is null, and the account instance is null; though null was not passed in for either.
      subItems was a simple (non persistent) list. Account is a persistent object though pulled from http session so it is detached.

        Issue Links

          Activity

          Hide
          Trevor Samaroo added a comment -

          I'm getting this with 2.0.3 as well. transient domain properties cannot be set in the Domain objects constructor. this is causing my app to null pointer unless i re-code how i construct domain objects. is there a workaround?

          thanks.

          Show
          Trevor Samaroo added a comment - I'm getting this with 2.0.3 as well. transient domain properties cannot be set in the Domain objects constructor. this is causing my app to null pointer unless i re-code how i construct domain objects. is there a workaround? thanks.
          Hide
          Rodrigo Rosenfeld Rosas added a comment -

          @Trevor, take a look at this related reported bug:

          http://jira.grails.org/browse/GRAILS-9098

          Unfortunately it was marked as "won't fix", but I guess you can set your transient properties as bindable as a workaround.

          Show
          Rodrigo Rosenfeld Rosas added a comment - @Trevor, take a look at this related reported bug: http://jira.grails.org/browse/GRAILS-9098 Unfortunately it was marked as "won't fix", but I guess you can set your transient properties as bindable as a workaround.
          Hide
          Harald L added a comment -

          I have still the same problem and the property isn't transient...

          class FieldDefinition

          { String fieldName FieldComparator fieldComperator Object fieldValue Object fieldValueBetweenRightBoundary }

          def x = new FieldDefinition( fieldName: "quantity", fieldComperator: FieldComparator.GREATER, fieldValue: 3.0 )

          will lead into that the x.fieldValue is null.
          I'm using Grails 2.1.4 and java version "1.6.0_45"

          Show
          Harald L added a comment - I have still the same problem and the property isn't transient... class FieldDefinition { String fieldName FieldComparator fieldComperator Object fieldValue Object fieldValueBetweenRightBoundary } def x = new FieldDefinition( fieldName: "quantity", fieldComperator: FieldComparator.GREATER, fieldValue: 3.0 ) will lead into that the x.fieldValue is null. I'm using Grails 2.1.4 and java version "1.6.0_45"
          Hide
          Jeff Scott Brown added a comment -

          Harald,

          Your fieldValue is not statically typed. Only statically typed properties which are not transient and not static are bindable by default. In order for fieldValue to be bindable it needs to be configued with bindable: true, or you need to assign the value explicitly like this:

          x.fieldValue = 3.0
          
          Show
          Jeff Scott Brown added a comment - Harald, Your fieldValue is not statically typed. Only statically typed properties which are not transient and not static are bindable by default. In order for fieldValue to be bindable it needs to be configued with bindable: true, or you need to assign the value explicitly like this: x.fieldValue = 3.0
          Hide
          Harald L added a comment -

          First off all I'm impressed of the response time! Many thanks for it.
          And you are right, after configuring the Object property as bindable true it was working.
          Many thanks

          Show
          Harald L added a comment - First off all I'm impressed of the response time! Many thanks for it. And you are right, after configuring the Object property as bindable true it was working. Many thanks

            People

            • Assignee:
              Graeme Rocher
              Reporter:
              John Hayward
            • Votes:
              5 Vote for this issue
              Watchers:
              12 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development