Sam Ng created OFBIZ-5332:
-----------------------------
Summary: GenericDelegator failed to cache NULL_VALUE
Key: OFBIZ-5332
URL:
https://issues.apache.org/jira/browse/OFBIZ-5332 Project: OFBiz
Issue Type: Bug
Components: framework
Affects Versions: Release Branch 12.04
Reporter: Sam Ng
GenericeDelegator should determine if the value is GenericValue.NULL_VALUE inside findOne(), otherwise, NULL_VALUE will be considered as cache missed.
And I have searched, although getFromPrimaryKeyCache() is public, but findOne() is the caller, so it is safe to change it's behavior.
According to my own test, if we fix this bug, about 1/3 of the DB queries will be removed (cache hit).
public GenericValue findOne(String entityName, Map<String, ? extends Object> fields, boolean useCache) throws GenericEntityException {
....
if (useCache) {
...
GenericValue value = this.getFromPrimaryKeyCache(primaryKey);
if (value != null) {
//========== change the following two line ==========
if ( value == GenericValue.NULL_VALUE ) return null;
else return value;
}
}
public GenericValue getFromPrimaryKeyCache(GenericPK primaryKey) {
.....
GenericValue value = cache.get(primaryKey);
//========== remove the following three lines ==========
// if (value == GenericValue.NULL_VALUE) {
// return null;
//}
return value;
}
--
This message was sent by Atlassian JIRA
(v6.1#6144)