So I ran into the same issue and as of spring-data-couchbase 3.x, you need to extend the MappingCouchBaseConverter and basically overwrite a bunch of methods (mostly copying private methods).
The actual change is in
protected void writeInternal(final Object source, final CouchbaseDocument target,
final CouchbasePersistentEntity<?> entity)
Where you will have to find the check for if (null != propertyObj)
and add an else block with:
else {
writeSimpleInternal(null, target, prop.getFieldName());
}
I feel like the spring team could probably just add an option to serialize null (or not) and then make this small change. But if you don't want to wait on those changes - just inherit from their class, overwrite and add the converter in your CouchBaseConfig as such:
@Override
public MappingCouchbaseConverter mappingCouchbaseConverter() throws Exception {
CustomMappingCouchbaseConverter converter = new CustomMappingCouchbaseConverter(couchbaseMappingContext(), typeKey());
converter.setCustomConversions(customConversions());
return converter;
}