|
31 | 31 | import java.util.Set;
|
32 | 32 | import java.util.function.Consumer;
|
33 | 33 |
|
| 34 | +import com.fasterxml.jackson.databind.ObjectMapper; |
34 | 35 | import org.springframework.core.convert.converter.Converter;
|
35 | 36 | import org.springframework.core.convert.converter.ConverterFactory;
|
36 | 37 | import org.springframework.core.convert.converter.GenericConverter;
|
|
39 | 40 | import org.springframework.data.convert.PropertyValueConverterFactory;
|
40 | 41 | import org.springframework.data.convert.PropertyValueConverterRegistrar;
|
41 | 42 | import org.springframework.data.convert.SimplePropertyValueConversions;
|
| 43 | +import org.springframework.data.couchbase.config.AbstractCouchbaseConfiguration; |
42 | 44 | import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
43 | 45 | import org.springframework.data.couchbase.core.mapping.CouchbaseSimpleTypes;
|
44 | 46 | import org.springframework.data.mapping.PersistentProperty;
|
@@ -145,6 +147,41 @@ public static CouchbaseConverterConfigurationAdapter from(List<?> converters) {
|
145 | 147 |
|
146 | 148 | CouchbaseConverterConfigurationAdapter converterConfigurationAdapter = new CouchbaseConverterConfigurationAdapter();
|
147 | 149 | converterConfigurationAdapter.registerConverters(converters);
|
| 150 | + // The following |
| 151 | + ObjectMapper om = new AbstractCouchbaseConfiguration() { |
| 152 | + @Override |
| 153 | + public String getConnectionString() { |
| 154 | + return null; |
| 155 | + } |
| 156 | + |
| 157 | + @Override |
| 158 | + public String getUserName() { |
| 159 | + return null; |
| 160 | + } |
| 161 | + |
| 162 | + @Override |
| 163 | + public String getPassword() { |
| 164 | + return null; |
| 165 | + } |
| 166 | + |
| 167 | + @Override |
| 168 | + public String getBucketName() { |
| 169 | + return null; |
| 170 | + } |
| 171 | + }.getObjectMapper(); |
| 172 | + List<Object> newConverters = new ArrayList(); |
| 173 | + newConverters.add(new OtherConverters.EnumToObject(om)); |
| 174 | + newConverters.add(new IntegerToEnumConverterFactory(om)); |
| 175 | + newConverters.add(new StringToEnumConverterFactory(om)); |
| 176 | + newConverters.add(new BooleanToEnumConverterFactory(om)); |
| 177 | + SimplePropertyValueConversions valueConversions = new SimplePropertyValueConversions(); |
| 178 | + valueConversions.setConverterFactory( |
| 179 | + new CouchbasePropertyValueConverterFactory(null, AbstractCouchbaseConfiguration.annotationToConverterMap(), om)); |
| 180 | + valueConversions.setValueConverterRegistry(new PropertyValueConverterRegistrar().buildRegistry()); |
| 181 | + valueConversions.afterPropertiesSet(); // wraps the CouchbasePropertyValueConverterFactory with CachingPVCFactory |
| 182 | + converterConfigurationAdapter.setPropertyValueConversions(valueConversions); |
| 183 | + converterConfigurationAdapter.registerConverters(newConverters); |
| 184 | + converterConfigurationAdapter.registerConverters(newConverters); |
148 | 185 | return converterConfigurationAdapter;
|
149 | 186 | }
|
150 | 187 |
|
|
0 commit comments