Closed
Description
Maciej Zasada opened DATACOUCH-27 and commented
@Id
annotated field is skipped by MappingCouchbaseConverter during convertion from CouchbaseDocument.
i.e. the following test will fail:
@Test
public void readsID() {
// given:
CouchbaseDocument converted = new CouchbaseDocument("001");
// when:
BasicCouchbasePersistentPropertyTests.Beer beer = converter.read(BasicCouchbasePersistentPropertyTests.Beer.class,
converted);
// then:
assertEquals("001", beer.getId());
}
IMO the problem lays in the following snippet:
entity.doWithProperties(new PropertyHandler<CouchbasePersistentProperty>() {
public void doWithPersistentProperty(final CouchbasePersistentProperty prop) {
if (!source.containsKey(prop.getFieldName()) || entity.isConstructorArgument(prop)) {
return;
}
Object obj = prop.isIdProperty() ? source.getId() : getValueInternal(prop, source, evaluator, result);
wrapper.setProperty(prop, obj, useFieldAccessOnly);
}
});
Codition !source.containsKey(prop.getFieldName()) || entity.isConstructorArgument(prop) will be satisfied while processing @Id
field, so it'll be skipped in the process
Affects: 1.0 M1