Project

General

Profile

bug #7331

Updated by Andreas Kohlbecker about 6 years ago

 
 In the `RegistrationWorkingSetService.loadWorkingSetByReferenceID(Integer referenceID)` a `RegistrationWorkingSet` is lodade with the following coede: 

 ~~~java 

 List<String> REGISTRATION_INIT_STRATEGY = Arrays.asList(new String []{ 
             "blockedBy", 
             // typeDesignation 
             "typeDesignations.typeStatus", 
             "typeDesignations.typifiedNames.typeDesignations", // important !! 
             "typeDesignations.typeSpecimen", 
             "typeDesignations.typeName.$", 
             "typeDesignations.citation", 
             "typeDesignations.citation.authorship.$", 
             // name 
             "name.$", 
             "name.nomenclaturalReference.authorship.$", 
             "name.nomenclaturalReference.inReference", 
             "name.rank", 
             "name.homotypicalGroup.typifiedNames", 
             "name.status.type", 
             "name.typeDesignations", // important !!" 
             // institution 
             "institution", 
             } 
     ); 

 Reference reference = repo.getReferenceService().find(referenceID); 
 Pager<Registration> pager = repo.getRegistrationService().page(Optional.of(reference), null, null, null, REGISTRATION_INIT_STRATEGY); 
 return new RegistrationWorkingSet(makeDTOs(pager.getRecords())); 

 ~~~ 

 This usually works, but with a specific data set the `pager` contains `Registrations` where `authorship` 
  properties of the `nomenclaturalReferences` are not initializes even if the `AdvancedBeanInitializer` apparently is doing the initialization properly (also confirmed by debugging): 

 ~~~ 
 
  TRACE [eu.et.cd.pe.da.in.AdvancedBeanInitializer] -    processing /name.nomenclaturalReference 
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] -    invoke initialization on /name.nomenclaturalReference beans of class TaxonName ...  
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load /name.nomenclaturalReference 
 /name.nomenclaturalReference.authorship.$ 
  TRACE [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load /name.nomenclaturalReference - DONE  
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] -    processing /name.nomenclaturalReference.authorship 
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] -    invoke initialization on /name.nomenclaturalReference.authorship beans of class Reference ...  
 User 
  TRACE [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load /name.nomenclaturalReference.authorship 
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load beans of class TeamOrPersonBase 
 [eu.et.cd.pe.da.in.AdvancedBeanInitializer] -    SELECT c FROM TeamOrPersonBase User as c    WHERE c.id IN (:idSet)  
  
  TRACE [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - initialize bulk loaded beans of class TeamOrPersonBase: [1383] 
 User: [10] 
  TRACE [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load - DONE 
 
  DEBUG [eu.et.cd.pe.da.in.AdvancedBeanInitializer] - bulk load /name.nomenclaturalReference.authorship.$ - DONE  
 ~~~  

 The actual initialization takes place in `AdvancedBeanInitializer.bulkLoadLazyBeans(BeanInitNode node)`.    Here a strange behavior can be observed in these special cases: 

 ~~~java 

 private void bulkLoadLazyBeans(node node) { 
         for (Class<?> clazz : node.getLazyBeans().keySet()){ 
             Set<Serializable> idSet = node.getLazyBeans().get(clazz); 
     String hql = " SELECT c FROM %s as c %s WHERE c.id IN (:idSet) "; 
     hql = String.format(hql, clazz.getSimpleName(), autoInit.leftJoinFetch); // hql = "SELECT c FROM TeamOrPersonBase as c    WHERE c.id IN (:idSet)"  
     Query query = genericDao.getHqlQuery(hql); 
     query.setParameterList("idSet", idSet); 
     List<Object> list = query.list(); 
 ~~~ 

 Now the TeamOrPersonBase entities are initialized. 
 **However, checking the `parent` object contained in the `node` object passed as parameer reveals that the 'authorship' proxy in the object graph has not been initialized.** 

 Preloading the reference in the    `RegistrationWorkingSetService.loadWorkingSetByReferenceID(Integer referenceID)` method avoids the problem (in the below code only relevant lines are shown) 

 ~~~java 

 Reference reference = repo.getReferenceService().find(referenceID); 
 repo.getReferenceService().load(reference.getUuid()); 

 ~~~ 


Back