Existing Groovy DSLs
[ 238 ]
Inheritance
By default, GORM implements inheritance relationships with a table-per-hierarchy.
A class column in the table is used as a discriminator column:
class Account {
double balance
}
class CardAccount extends Account {
String cardId
}
class CreditAccount extends Account{
double creditLimit
}
All of the properties from the hierarchy are mapped to columns in an account table.
Entries in the table will have the class column set to indicate what class the object in
the entry belongs to.
Mapping
We can use the mapping setting to apply a table-per-subclass strategy to inheritance
mapping. This will overcome the need to allow all properties to be nullable.
Mapping also allows us to map GORM domain classes onto a legacy database as it
gives us fine control over both table and column names in the relational model that
we map to:
class Account {
double balance
static mapping = {
table "fin_account"
balance column:"acc_bal"
}
}
http://www.ebook3000.com