Avoid complications with merges in the session cache, evict and then update.
This commit is contained in:
parent
e1884cf52d
commit
857eadff45
1 changed files with 5 additions and 16 deletions
|
@ -234,7 +234,7 @@ public class HelenusSession extends AbstractSessionOperations implements Closeab
|
||||||
}
|
}
|
||||||
String tableName = CacheUtil.schemaName(facets);
|
String tableName = CacheUtil.schemaName(facets);
|
||||||
List<String[]> facetCombinations = CacheUtil.flattenFacets(boundFacets);
|
List<String[]> facetCombinations = CacheUtil.flattenFacets(boundFacets);
|
||||||
mergeAndUpdateCacheValues(pojo, tableName, facetCombinations);
|
replaceCachedFacetValues(pojo, tableName, facetCombinations);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -265,10 +265,9 @@ public class HelenusSession extends AbstractSessionOperations implements Closeab
|
||||||
boundFacets.add(facet);
|
boundFacets.add(facet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// NOTE: should equal `String tableName = CacheUtil.schemaName(facets);`
|
|
||||||
List<String[]> facetCombinations = CacheUtil.flattenFacets(boundFacets);
|
List<String[]> facetCombinations = CacheUtil.flattenFacets(boundFacets);
|
||||||
String tableName = CacheUtil.schemaName(boundFacets);
|
String tableName = CacheUtil.schemaName(boundFacets);
|
||||||
mergeAndUpdateCacheValues(pojo, tableName, facetCombinations);
|
replaceCachedFacetValues(pojo, tableName, facetCombinations);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,21 +283,11 @@ public class HelenusSession extends AbstractSessionOperations implements Closeab
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void mergeAndUpdateCacheValues(Object pojo, String tableName, List<String[]> facetCombinations) {
|
private void replaceCachedFacetValues(Object pojo, String tableName, List<String[]> facetCombinations) {
|
||||||
Object merged = null;
|
|
||||||
for (String[] combination : facetCombinations) {
|
for (String[] combination : facetCombinations) {
|
||||||
String cacheKey = tableName + "." + Arrays.toString(combination);
|
String cacheKey = tableName + "." + Arrays.toString(combination);
|
||||||
Object value = sessionCache.get(cacheKey);
|
sessionCache.invalidate(cacheKey);
|
||||||
if (value == null) {
|
sessionCache.put(cacheKey, pojo);
|
||||||
sessionCache.put(cacheKey, pojo);
|
|
||||||
} else {
|
|
||||||
if (merged == null) {
|
|
||||||
merged = pojo;
|
|
||||||
} else {
|
|
||||||
merged = CacheUtil.merge(value, pojo);
|
|
||||||
}
|
|
||||||
sessionCache.put(cacheKey, merged);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue