Propagated CouchbaseCustomConverters bean into MappingConverter (#1885)
* Propagated CouchbaseCustomConverters bean into MappingConverter. Just a polishing fix to propagate CouchbaseCustomConversions directly to MappingCouchbaseConverter -> AbstractCouchbaseConverter , So that we won't have to set it explicitly. * Removed unnecessary constructor.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import org.springframework.data.couchbase.core.convert.CouchbaseCustomConversions;
|
||||
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
||||
@@ -37,8 +38,9 @@ public class AbstractingMappingCouchbaseConverter extends MappingCouchbaseConver
|
||||
*/
|
||||
public AbstractingMappingCouchbaseConverter(
|
||||
final MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> mappingContext,
|
||||
final String typeKey) {
|
||||
super(mappingContext, typeKey);
|
||||
final String typeKey,
|
||||
final CouchbaseCustomConversions couchbaseCustomConversions) {
|
||||
super(mappingContext, typeKey, couchbaseCustomConversions);
|
||||
this.typeMapper = new AbstractingTypeMapper(typeKey);
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,7 @@ public class Config extends AbstractCouchbaseConfiguration {
|
||||
// that has an getAliasFor(info) that just returns getType().getName().
|
||||
// Our CustomMappingCouchbaseConverter uses a TypeBasedCouchbaseTypeMapper that will
|
||||
// use the DocumentType annotation
|
||||
MappingCouchbaseConverter converter = new CustomMappingCouchbaseConverter(couchbaseMappingContext, typeKey());
|
||||
converter.setCustomConversions(couchbaseCustomConversions);
|
||||
MappingCouchbaseConverter converter = new CustomMappingCouchbaseConverter(couchbaseMappingContext, typeKey(), couchbaseCustomConversions);
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.couchbase.domain;
|
||||
|
||||
import org.springframework.data.couchbase.core.convert.CouchbaseCustomConversions;
|
||||
import org.springframework.data.couchbase.core.convert.MappingCouchbaseConverter;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentEntity;
|
||||
import org.springframework.data.couchbase.core.mapping.CouchbasePersistentProperty;
|
||||
@@ -37,4 +38,21 @@ public class CustomMappingCouchbaseConverter extends MappingCouchbaseConverter {
|
||||
this.typeMapper = new TypeBasedCouchbaseTypeMapper(typeKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* this constructer creates a TypeBasedCouchbaseTypeMapper with the specified couchbaseCustomConversions and typeKey
|
||||
* while MappingCouchbaseConverter uses a DefaultCouchbaseTypeMapper typeMapper = new DefaultCouchbaseTypeMapper(typeKey != null ? typeKey :
|
||||
* TYPEKEY_DEFAULT);
|
||||
*
|
||||
* @param mappingContext
|
||||
* @param typeKey - the typeKey to be used (normally "_class")
|
||||
* @param couchbaseCustomConversions - custom conversions to use
|
||||
*/
|
||||
public CustomMappingCouchbaseConverter(
|
||||
final MappingContext<? extends CouchbasePersistentEntity<?>, CouchbasePersistentProperty> mappingContext,
|
||||
final String typeKey,
|
||||
final CouchbaseCustomConversions couchbaseCustomConversions) {
|
||||
super(mappingContext, typeKey, couchbaseCustomConversions);
|
||||
this.typeMapper = new TypeBasedCouchbaseTypeMapper(typeKey);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -124,8 +124,8 @@ public class CouchbaseAbstractRepositoryIntegrationTests extends ClusterAwareInt
|
||||
// Our CustomMappingCouchbaseConverter uses a TypeBasedCouchbaseTypeMapper that will
|
||||
// use the DocumentType annotation
|
||||
MappingCouchbaseConverter converter = new AbstractingMappingCouchbaseConverter(couchbaseMappingContext,
|
||||
typeKey());
|
||||
converter.setCustomConversions(couchbaseCustomConversions);
|
||||
typeKey(),
|
||||
couchbaseCustomConversions);
|
||||
return converter;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user