FIX: correct caching when collection with different inherited beans is put to the cache (#1379)

* FIX: correct cahcing when collection with different inherited beans is put to the cache

* removed some sysouts
This commit is contained in:
Roland Praml
2018-05-20 16:53:56 +12:00
committed by Rob Bygrave
parent d1b7b082a2
commit ab301f970c
3 changed files with 63 additions and 2 deletions
@@ -447,7 +447,21 @@ final class BeanDescriptorCacheHelp<T> {
void beanPutAll(Collection<EntityBean> beans) {
if (desc.inheritInfo != null) {
Class<?> aClass = theClassOf(beans);
desc.descOf(aClass).cacheBeanPutAllDirect(beans);
// check if all beans have the same class
for (EntityBean bean : beans) {
if (!bean.getClass().equals(aClass)) {
aClass = null;
break;
}
}
if (aClass == null) {
// there are different bean types in the collection, so we add one by one to the cache
for (EntityBean bean : beans) {
desc.descOf(bean.getClass()).cacheBeanPutDirect(bean);
}
} else {
desc.descOf(aClass).cacheBeanPutAllDirect(beans);
}
} else {
beanCachePutAllDirect(beans);
}