更新时间:2023-02-18 20:55:51
如此处您应该覆盖默认的SPMappingCouchbaseConverter.
As explained here you should override the default SPMappingCouchbaseConverter.
这是我解决问题的方法:
Here is how I solved the problem:
@Bean
public MappingCouchbaseConverter mappingCouchbaseConverter() throws Exception {
return new MyMappingCouchbaseConverter(couchbaseMappingContext());
}
private class MyMappingCouchbaseConverter extends MappingCouchbaseConverter {
MyMappingCouchbaseConverter(MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> mappingContext) {
super(mappingContext);
}
@Override
@SuppressWarnings("unchecked")
protected <R> R read(final TypeInformation<R> type, final CouchbaseDocument source, final Object parent) {
if (Object.class == typeMapper.readType(source, type).getType()) {
return (R) source.export();
} else {
return super.read(type, source, parent);
}
}
}