I have Two domains.
class ABC{
String xyz
static mapping = {
discriminator column: 'ABC_TYPE_ID'
}
}
and
class XYZ extends ABC{
static mapWith = "none"
static mapping = {
discriminator value: 3
}
}
In Grails 2.5.5 below line works perfectly fine but after making the required changes it is not working in Grails-3.2.4 and is giving null.
Mapping mapping = new GrailsDomainBinder().getMapping(XYZ) //Works fine Grails 2.5.5
Mapping mapping = GrailsDomainBinder.getMapping(XYZ) // Giving null in Grails-3.2.4
Please help me in getting the Mapping object from the XYZ domain.
My findings:
I am using oracle db with commented #dbCreate:'' in application.yml.
After commenting static mapWith = "none" in XYZ domain i am getting the Mapping object and the corresponding table is not created in DB because of #dbCreate:''.
Are there any issue with this approach? if yes please provide me with alternative solutions.
The static state part has been removed in recent versions of GORM. You need to use the
MappingContext
object to get what you want:See http://gorm.grails.org/latest/hibernate/api/org/grails/datastore/mapping/model/MappingContext.html