Grails
  1. Grails
  2. GRAILS-8267

Where queries do not support properties of extened classes on associations

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-RC1
    • Fix Version/s: 2.0-RC2
    • Component/s: Persistence
    • Labels:
      None

      Description

      Example:

      Provider.groovy
      class Provider  {
          User user
          BillingAccount billingAccount
          String businessName
      
          static hasMany = [locations: ProviderAddress]
      
          static constraints = {
              user nullable:false
              billingAccount nullable: true
              businessName(nullable: true)
          }
      
      }
      
      ProviderAddress.groovy
      class ProviderAddress extends Address{
          Provider provider
      
          static constraints = {
          }
      }
      
      Address.groovy
      abstract class Address {
      
          String address1
          String address2
          String city
          State state
          String zip
          String country
      
          Date dateCreated
          Date lastUpdated
      
          static constraints = {
      
              address1(blank: false, maxLength: 100)
              address2(nullable: true, maxLength: 100)
              city(blank: false, maxLength: 100)
              state(blank: false, maxLength: 100)
              zip(blank: false, maxLength: 10)
              country(nullable: true, maxLength: 100)
          }
      }
      

      This is the query:

              def query = Provider.where {
                 locations {zip in zipList }
              }
      

      Error:

      | Error 2011-11-06 02:33:20,962 [Thread-43] ERROR compiler.GrailsProjectWatcher  - Compilation Error: startup failed:
                    locations {zip in zipList }
                               ^
      ProviderService.groovy: 71: Cannot query on property "zip" - no such property on class com.sb.ProviderAddress exists.
      
      

        Activity

        Show
        Graeme Rocher added a comment - fixed by https://github.com/SpringSource/grails-data-mapping/commit/534893f3e3ceb429fb902acbf43ad8b1960285f7

          People

          • Assignee:
            Graeme Rocher
            Reporter:
            John Thompson
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development