Hi all following is the situation I have an abstract class AbstractProfile and one concrete class GoogleProfile
abstract class AbstractProfile {
.....
}
class GoogleProfile extends AbstractProfile {
......
}
I am using grails but gorm is not inserting table for google profile current gorm is inserting table for only AbstractProfile class please help Thanks in advance
Grails 2.0 persists abstract classes. In order to enable an individual table to the extending class, you need to specify:
to the abstract class. Otherwise the whole hierarchy will "live" in the same table.
I did some digging and found out that starting on grails 2.3 you have the following mapping option:
It seems the documentation (even for version 2.4) hasn't been updated regarding this yet.
Following up on Михаил's great answer, two separate things worked for me.
This worked best for me because both the constraints from the base class and the subclass were applied. Having not null columns in the subclasses was important for my use case. However, it appears that only the mapping block from the subclass is used.
tablePerConcreteClass true
An advantage here is it allows an index to be declared in the BaseDomain class that then appears in each of the subclass tables, ie both the mapping blocks from the base class and subclass are used. Only the constraints in the base class appear to be used.
You can use this :