-
-
Notifications
You must be signed in to change notification settings - Fork 969
Open
Description
Domains like Certificate and SpecialCert extends Certificate. Things work well. _class is added to each document when doing inserts.
However, since upgrade to grails 2.5.2 and 3.0.3 version of the mongo plugin I now have a problem when adding dynamic attributes before the first save. It causes the _class not to be inserted into mongo, and this in turn causes something like SpecialCert.get(id) to not return the document later.
There is a workaround. Just do the .save() first then add the props and do another .save(), but it is a definite gotcha.
if (!specialCert.hasErrors()) {
specialCert.save()
// for some reason if we try to stamp the markerKey before the first .save() GORM mongo
// loses that what class this is and misses putting the _class into the DB causing probs later
String markerKey = ourService.getMarkerKey()
if (markerKey) specialCert['markerKey'] = markerKey
specialCert.save()
}Reactions are currently unavailable