Merge pull request #5 from mzasada/DATACOUCH-27
DATACOUCH-27: Mapping @Id field with MappingCouchbaseConverter
This commit is contained in:
@@ -82,7 +82,7 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
protected <R> R read(TypeInformation<R> type, CouchbaseDocument doc) {
|
||||
return read(type, doc, null);
|
||||
}
|
||||
|
||||
|
||||
protected <R> R read(TypeInformation<R> type, final CouchbaseDocument source, Object parent) {
|
||||
|
||||
if (source == null) {
|
||||
@@ -118,13 +118,17 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
|
||||
entity.doWithProperties(new PropertyHandler<CouchbasePersistentProperty>() {
|
||||
public void doWithPersistentProperty(final CouchbasePersistentProperty prop) {
|
||||
if (!source.containsKey(prop.getFieldName()) || entity.isConstructorArgument(prop)) {
|
||||
if (!doesPropertyExistInSource(prop) || entity.isConstructorArgument(prop)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Object obj = prop.isIdProperty() ? source.getId() : getValueInternal(prop, source, evaluator, result);
|
||||
wrapper.setProperty(prop, obj, useFieldAccessOnly);
|
||||
}
|
||||
|
||||
private boolean doesPropertyExistInSource(CouchbasePersistentProperty property) {
|
||||
return property.isIdProperty() || source.containsKey(property.getFieldName());
|
||||
}
|
||||
});
|
||||
|
||||
entity.doWithAssociations(new AssociationHandler<CouchbasePersistentProperty>() {
|
||||
@@ -201,7 +205,6 @@ public class MappingCouchbaseConverter extends AbstractCouchbaseConverter
|
||||
return target.isAssignableFrom(value.getClass()) ? value : conversionService.convert(value, target);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void write(final Object source, final CouchbaseDocument target) {
|
||||
if (source == null) {
|
||||
|
||||
Reference in New Issue
Block a user