By default GORM classes uses
table-per-hierarchy
inheritance mapping. This has the disadvantage that columns cannot have a
NOT-NULL
constraint applied to them at the db level. If you would prefer to use a
table-per-subclass
inheritance strategy you can do so as follows:
class Payment {
Long id
Long version
Integer amount static mapping = {
tablePerHierarchy false
}
}
class CreditCardPayment extends Payment {
String cardNumber
}
The mapping of the root
Payment
class specifies that it will not be using
table-per-hierarchy
mapping for all child classes.