0

I am saving instance in mongodb but getting some null properties saved. I have used below configuration in Application.yml to use MongoSession

grails:
mongodb:
   engine: mapping

I am using below code for saving my instance but it was saving null properties of instance also, which I don't want.

instance.save(validate: false, flush: true)

Thanks for the help in advance!

  • Off the top of my head I think that's the normal behavoir with GORM. I believe you can mark properties as `nullable` so they have `null` when not initialized instead of empty strings or other default values, but that is as far as it goes. GORM is initially designed with "relational databases" in mind. So "MongoDB(esque)" things like not storing all of the properties is not actually a native concept to an RDBMS. – Neil Lunn Nov 20 '18 at 05:55
  • I have initialized properties as null but I want to filter those before saving. In the previous version of grails 3.0, save was ignoring null values to be saved in mongodb – K142130 Muhammad Zaid Khan Nov 20 '18 at 06:21

0 Answers0