FIX: Json deserialize references

This commit is contained in:
Jonas Pöhler
2021-11-16 11:57:30 +01:00
committed by Noemi Szemenyei
parent 5807874c9e
commit d3e07defa0
3 changed files with 15 additions and 7 deletions
@@ -3038,6 +3038,10 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
return ebi.isReference() || referenceIdPropertyOnly(ebi);
}
boolean hasIdPropertyOnly(EntityBeanIntercept ebi) {
return propertiesBaseScalar.length > 0 && ebi.hasIdOnly(idPropertyIndex);
}
public boolean referenceIdPropertyOnly(EntityBeanIntercept ebi) {
return idOnlyReference && ebi.hasIdOnly(idPropertyIndex);
}
@@ -3055,6 +3059,12 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType, SpiBeanType {
return versionPropertyIndex > -1 && ebi.isLoadedProperty(versionPropertyIndex);
}
void setReferenceIfIdOnly(EntityBeanIntercept ebi) {
if (hasIdPropertyOnly(ebi)) {
ebi.setReference(idPropertyIndex);
}
}
/**
* Set the version value returning it in primitive long form.
*/
@@ -152,6 +152,9 @@ final class BeanDescriptorJsonHelp<T> {
}
if (contextBean == null) {
readJson.beanVisitor(bean, unmappedProperties);
if (!isNullOrZero(id)) {
desc.setReferenceIfIdOnly(bean._ebean_getIntercept());
}
}
if (path != null) {
readJson.popPath();