7.2.2 Composition in GORM - Reference Documentation
Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari
Version: 3.1.9
7.2.2 Composition in GORM
As well as association, Grails supports the notion of composition. In this case instead of mapping classes onto separate tables a class can be "embedded" within the current table. For example:class Person { Address homeAddress Address workAddress static embedded = ['homeAddress', 'workAddress'] }class Address { String number String code }

If you define theAddress
class in a separate Groovy file in thegrails-app/domain
directory you will also get anaddress
table. If you don't want this to happen use Groovy's ability to define multiple classes per file and include theAddress
class below thePerson
class in thegrails-app/domain/Person.groovy
file