I am having a problem setting up a List as a hasMany relationship to a belongsTo withing an extended class.
With a new Grails 2.4.4 app I have these 3 Domains:
An Author class having many books.
class Author {
List books
static hasMany = [books: Book]
}
A Book class which extends Content
class Book extends Content {
String foo
}
And Content, which has a number of common properties.
class Content {
String title
static belongsTo = [author: Author]
static constraints = {
sort: 'title'
}
}
When running this application I get the following exception:
Caused by: org.hibernate.MappingException: Repeated column in mapping for entity: test.relationships.Book column: author_id (should be mapped with insert="false" update="false")
I only get this exception when I make books a List.
books
as a list? I think it's treated as a list by default from thehasMany
notation such that you don't need to define it as a separate variable. Hence your "repeated column." Just a guess. – Marcbooks
would be a set. I think specifying the type like this is the correct way to ensure that thebooks
collection is mapped as a list. – rcgeorge23