Merge pull request #2310 from FOCONIS/nutation-on-cache

FIX: mutation info is not restored on cache hit
This commit is contained in:
Rob Bygrave
2021-08-15 13:50:19 +12:00
committed by GitHub
2 changed files with 33 additions and 1 deletions
@@ -5,6 +5,7 @@ import io.ebean.bean.EntityBean;
import io.ebean.bean.EntityBeanIntercept;
import io.ebean.bean.MutableValueInfo;
import io.ebean.bean.MutableValueNext;
import io.ebean.bean.PersistenceContext;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.ScalarType;
import io.ebean.text.TextException;
@@ -104,6 +105,18 @@ public class BeanPropertyJsonMapper extends BeanPropertyJsonBasic {
throw new PersistenceException("Error readSet on " + descriptor + "." + name, e);
}
}
@Override
public void setCacheDataValue(EntityBean bean, Object cacheData, PersistenceContext context) {
if (cacheData instanceof String) {
// parse back from string to support optimisation of java object serialisation
final MutableValueInfo hash = createMutableInfo((String)cacheData);
bean._ebean_getIntercept().mutableInfo(propertyIndex, hash);
cacheData = scalarType.parse((String) cacheData);
}
setValue(bean, cacheData);
}
private static final class NextPair implements MutableValueNext {