mirror of
https://github.com/ebean-orm/ebean.git
synced 2024-04-21 10:51:47 +00:00
#1811 Fix for Entity with EmbeddedId not found in cache
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user