#1785 - Bean gets replaced on json deserialization with primitive 'null' id

This commit is contained in:
rob bygrave
2019-08-12 21:05:32 +12:00
parent ee6452cfb0
commit f5459920e9
7 changed files with 45 additions and 11 deletions
@@ -112,6 +112,8 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
/**
* Describes Beans including their deployment information.
*/
@@ -3210,7 +3212,7 @@ public class BeanDescriptor<T> implements BeanType<T>, STreeType {
}
boolean hasIdValue(EntityBean bean) {
return (idProperty != null && !DmlUtil.isNullOrZero(idProperty.getValue(bean)));
return (idProperty != null && !isNullOrZero(idProperty.getValue(bean)));
}
boolean hasVersionProperty(EntityBeanIntercept ebi) {
@@ -14,6 +14,8 @@ import java.io.IOException;
import java.util.LinkedHashMap;
import java.util.Map;
import static io.ebeaninternal.server.persist.DmlUtil.isNullOrZero;
class BeanDescriptorJsonHelp<T> {
private final BeanDescriptor<T> desc;
@@ -158,7 +160,7 @@ class BeanDescriptorJsonHelp<T> {
}
Object contextBean = null;
Object id = desc.beanId(bean);
if (id != null) {
if (!isNullOrZero(id)) {
// check if the bean has already been loaded
contextBean = readJson.persistenceContextPutIfAbsent(id, bean, desc);
}