When I try to persist @Document
using CrudRepository
, all null fields in the object does not get written to the database.
Example (Object obj):
{
"field1": {
"field11": 123
},
"field2": null,
"field3": "abc"
}
objRepo.save(obj)
, field2 will not get written to Couchbase.
Is there a possibility to override the behavior of spring repository to save nulls? Do I have to create my own MappingCouchbaseConverter
or maybe it have to do with the TranslationService
?
There's no support for storing the nulls explicitly right now, so you might have to tinker with MappingCouchbaseConverter
. I think modifying one of the writeInternal
methods would be a good start: something like doing writeSimpleInternal(null, target, prop.getFieldName());
for the null case...