Search code examples
grailsgrails-orm

Grails non-existent mapping property


Having problems with domain class mappings. The domains are as follows:

User Domain

class User extends SecUser {
   static hasMany = [ratings:Rating, searchedResults:Results, recommendedResults:Results]
   static mappedBy = [searchedResults:"searched", recommendedResults:"recommended"]
}

Rating Domain

class Rating {
   static belongsTo = User

   Artist artist
   double rating
}   

Results Domain

class Results {
   static belongsTo = User

   def searched
   def recommended
}

When compiling it gives following error:

 Non-existent mapping property [recommended] specified for property [recommendedResults] in class [class ontourtest.User].

Any ideas why this is happening? Thanks very much!


Solution

  • Try changing the def searched and def recommended in the Results class to their actual types (example Thing searched, Thing recommended). I'm not sure what type they're supposed to be and i think grails doesn't know either.

    See the documentation

    Note: there is a type-o in the documentation ;)