#1811 Fix for Entity with EmbeddedId not found in cache

This commit is contained in:
rob bygrave
2019-09-11 22:28:22 +12:00
parent faba55d772
commit 6fddd418a1
2 changed files with 16 additions and 4 deletions
@@ -835,6 +835,13 @@ public class BeanProperty implements ElPropertyValue, Property, STreeProperty {
return scalarType.format(value);
}
/**
* Return the value from String format into Object value.
*/
public Object parse(String value) {
return scalarType.parse(value);
}
/**
* Read the value for this property from L2 cache entry and set it to the bean.
* <p>
@@ -263,11 +263,9 @@ public final class IdBinderEmbedded implements IdBinder {
public Object convertIdFromJson(Object value) {
Map<String, Object> map = (Map<String, Object>) value;
EntityBean idValue = idDesc.createEntityBean();
for (BeanProperty prop : props) {
Object val = map.get(prop.getName());
prop.setValue(idValue, val);
prop.setValue(idValue, map.get(prop.getName()));
}
return idValue;
}
@@ -465,7 +463,14 @@ public final class IdBinderEmbedded implements IdBinder {
@Override
public Object convertId(Object idValue) {
// can not cast/convert if it is embedded
if (idValue instanceof String) {
final EntityBean embId = idDesc.createEntityBean();
final String[] rawVals = ((String)idValue).split("\\|");
for (int i = 0; i < props.length; i++) {
props[i].setValue(embId, props[i].parse(rawVals[i]));
}
return embId;
}
return idValue;
}