CHAPTER 7: Rapid Web Development with Grails 349
Grails maps a many-to-many relationship using a join table at the database level. The owning side of
the relationship, Author in this application, takes responsibility for persisting the relationship because
Grails uses Hibernate as ORM frameworks and, in Hibernate, only one side of a many-to-many
relationship can take responsibility for managing the relationship.
With the relationship between the domain classes created, all you need to do is to create
BookController and AuthorController and set their scaffold property. In the BookController you
created, replace the index() action with the scaffold property set to Book, as illustrated in Listing 7-34.
Listing 7-34. BookController
class BookController {
static scaffold = Book
}
In the AuthorController, set the scaffold property to Author, as illustrated in Listing 7-35.
Listing 7-35. AuthorController
class AuthorController {
static scaffold = Author
}
Now you can run the application. The scaffolding will generate the application for you and point you
to the URL. Figure 7-32 shows the welcome screen of the application.
Figure 7-32. Welcome screen of book application