gorm-hibernate5 icon indicating copy to clipboard operation
gorm-hibernate5 copied to clipboard

Many to Many with BaseClass and tablePerHierarchy false

Open tmanthey opened this issue 6 years ago • 1 comments

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']
    }
}

tmanthey avatar Dec 03 '18 19:12 tmanthey

I'm having a similar problem, when using tablePerHierarchy false, i lost subclass schema mapping and consequently, relation not found error.

rodolfosaraiva avatar May 13 '21 20:05 rodolfosaraiva