Grails不存在的映射属性

时间:2011-07-22 11:31:09

标签: grails gorm

遇到域类映射问题。域名如下:

用户域

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

评分域

class Rating {
   static belongsTo = User

   Artist artist
   double rating
}   

结果域

class Results {
   static belongsTo = User

   def searched
   def recommended
}

编译时会出现以下错误:

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

为什么会发生这种情况?非常感谢!

1 个答案:

答案 0 :(得分:4)

尝试将def searched课程中的def recommendedResults更改为实际类型(例如Thing searchedThing recommended)。我不确定他们应该是什么类型,我认为grails也不知道。

请参阅documentation

注意:文档中有一个类型o;)