gorm-hibernate5
gorm-hibernate5 copied to clipboard
Many to Many with BaseClass and tablePerHierarchy false
Based on the official example the following example will fail with
org.hibernate.AssertionFailure: Table mm_author_books not found
As the the similar unidirectional many-to-many mapping works just as expected with even the potentially identical mapping table I assume it's a bug.
UPDATE: if you use tablePerConcreteClass true
instead of tablePerHierarchy false
it works. As we dont use an abstract base class both will create the same DB-mapping.
class SomeBase {
static mapping = {
tablePerHierarchy false
}
}
class Book extends SomeBase {
String title
static belongsTo = Author
static hasMany = [authors: Author]
static mapping = {
authors joinTable: [name: "mm_author_books", key: 'mm_book_id' ]
}
}
class Author extends SomeBase {
String name
List books
static hasMany = [books: Book]
static mapping = {
books joinTable: [name: "mm_author_books", key: 'mm_author_id']
}
}
I'm having a similar problem, when using tablePerHierarchy false, i lost subclass schema mapping and consequently, relation not found error.