More Than Five
More Than Five

Reputation: 10429

Unidirectional 1:M relationship uses join table by default

In Grails, a UniDirectional 1:M relationship uses a join table by default. See: http://grails.org/doc/2.3.7/guide/GORM.html#oneToMany

Why is this?

And is there anyway to stop this behaviour.

Thanks

Upvotes: 0

Views: 53

Answers (1)

dmahapatro
dmahapatro

Reputation: 50275

To avoid the join table in unidirectional 1:M, foreign key has to be specified in the parent for the associations:

class Book {

    static hasMany = [authors: Author]

    static mapping = {
        authors column: 'BOOK_AUTHOR_ID'
    }
}

Upvotes: 1

Related Questions