Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
-
None
Description
I'm finding that primitive fields that aren't set on a thrift model, like long, are mapped into entities as a 0. The Dozer mapping (see ObjectMapperSingleton) isn't calling isSet on the thrift models to make sure that they are mapped.
Here's some pseudo code that I think would do the trick, although I'm not sure if a CustomFieldMapper is the right way to customize this in Dozer (seemed like the best option given the research I did):
public static ObjectMapperSingleton getInstance(){ if(instance == null) { instance = new ObjectMapperSingleton(); instance.setCustomFieldMapper(new CustomFieldMapper() { @Override public boolean mapField(Object source, Object destination, Object sourceFieldValue, ClassMap classMap, FieldMap fieldMap) { if (source instanceof TBase) { TBase thriftSource = (TBase) source; // TODO: following doesn't work, needs reflection srcField = thriftSource.getClass()._Fields.byName(fieldMap.getSrcFieldName()); if (!thriftSource.isSet(srcField)) { // Just skipping mapping field if not set on Thrift source model return true; } } return false; } }); } return instance; }
Attachments
Issue Links
- is related to
-
AIRAVATA-2872 registry-refactoring: OpenJPA doesn't persist setting a field to null
- Resolved