Many to Many with BaseClass and tablePerHierarchy false
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
Based on the [official example](http://docs.grails.org/3.0.17/ref/Database%20Mapping/joinTable.html) 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']
}
}
```
Contributor guide
Research direction
Start with the SomeBase, Book, and Author mappings shown in the issue and reproduce the failure using tablePerHierarchy false. Compare the generated join-table behavior with tablePerConcreteClass true; done means the mm_author_books table is found and the many-to-many mapping works as in the unidirectional case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- database
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100