DistributionInfoDTO dto = new DistributionInfoDTO();\r
\r
// Adding default initStrategies to improve the performance of this method\r
- // adding 'status' and 'area.parentOf' has a good positive effect:\r
+ // adding 'status' and 'area' has a good positive effect:\r
// filterDistributions() only takes 21% of the total method time (before it was 46%)\r
// at the same time the cost of the getDescriptionElementForTaxon is not increased at all!\r
//\r
if(!initStrategy.contains("status")) {\r
initStrategy.add("status");\r
}\r
- if(!initStrategy.contains("area.parentOf")) {\r
- initStrategy.add("area.parentOf");\r
+ if(!initStrategy.contains("area")) {\r
+ initStrategy.add("area");\r
}\r
if(!initStrategy.contains("markers.markerType")) {\r
initStrategy.add("markers.markerType");\r
import java.beans.PropertyDescriptor;\r
import java.io.Serializable;\r
import java.lang.reflect.InvocationTargetException;\r
+import java.lang.reflect.ParameterizedType;\r
+import java.lang.reflect.Type;\r
import java.util.ArrayList;\r
import java.util.Collection;\r
import java.util.Collections;\r
}\r
//new\r
for (Object parentBean : parentBeans){\r
+ String propertyName = mapFieldToPropertyName(property, parentBean.getClass().getSimpleName());\r
try{\r
- Object propertyValue = PropertyUtils.getProperty(parentBean, mapFieldToPropertyName(property, parentBean.getClass().getSimpleName()));\r
+ Object propertyValue = PropertyUtils.getProperty(parentBean, propertyName);\r
preparePropertyValueForBulkLoadOrStore(node, parentBean, property, propertyValue);\r
} catch (IllegalAccessException e) {\r
logger.error("Illegal access on property " + property);\r
} catch (InvocationTargetException e) {\r
logger.error("Cannot invoke property " + property + " not found");\r
} catch (NoSuchMethodException e) {\r
- if (logger.isDebugEnabled()){logger.debug("Property " + property + " not found for class " + parentClazz);}\r
+ if (logger.isDebugEnabled()){logger.debug("Property " + propertyName + " not found for class " + parentClazz);}\r
}\r
}\r
\r
if (idSet != null && ! idSet.isEmpty()){\r
if (logger.isTraceEnabled()){logger.trace("bulk load " + node + " collections ; ownerClass=" + ownerClazz.getSimpleName() + " ; param = " + param);}\r
\r
+ Type collectionEntitiyType = null;\r
+ PropertyDescriptor[] descriptors = PropertyUtils.getPropertyDescriptors(ownerClazz);\r
+ for(PropertyDescriptor d : descriptors) {\r
+ if(d.getName().equals(param)) {\r
+ ParameterizedType pt = (ParameterizedType) d.getReadMethod().getGenericReturnType();\r
+ collectionEntitiyType = pt.getActualTypeArguments()[0];\r
+ }\r
+ }\r
+\r
//TODO use entity name ??\r
//get from repository\r
List<Object[]> list;\r
String hql = "SELECT oc " +\r
- " FROM %s as oc JOIN FETCH oc.%s as col %s " +\r
+ " FROM %s as oc LEFT JOIN FETCH oc.%s as col %s" +\r
" WHERE oc.id IN (:idSet) ";\r
\r
-// String hql = "SELECT oc.%s " +\r
-// " FROM %s as oc WHERE oc.id IN (:idSet) ";\r
hql = String.format(hql, ownerClazz.getSimpleName(), param,\r
- "" /*addAutoinitFetchLoading(clazz, "col")*/);\r
+ addAutoinitFetchLoading((Class)collectionEntitiyType, "col"));\r
\r
try {\r
if (logger.isTraceEnabled()){logger.trace(hql);}\r
Query query = genericDao.getHqlQuery(hql);\r
query.setParameterList("idSet", idSet);\r
list = query.list();\r
+ if (logger.isTraceEnabled()){logger.trace("size of retrieved list is " + list.size());}\r
} catch (HibernateException e) {\r
e.printStackTrace();\r
throw e;\r
if (newBean instanceof HibernateProxy){\r
newBean = initializeInstance(newBean);\r
}\r
- autoinitializeBean(newBean);\r
+ // no longer needed since the hql is getting the AutoinitFetchLoading statements\r
+// autoinitializeBean(newBean);\r
node.addBean(newBean);\r
}\r
}\r
for (AbstractPersistentCollection collection : node.getUninitializedCollections()){\r
if (! collection.wasInitialized()){ //should not happen anymore\r
collection.forceInitialization();\r
+ if (logger.isTraceEnabled()){logger.trace("forceInitialization of collection " + collection);}\r
+ } else {\r
+ if (logger.isTraceEnabled()){logger.trace("collection " + collection + " is initialized - OK!");}\r
}\r
}\r
\r