Project

General

Profile

Revision 390d8116

ID390d8116fe6a462337314aaf354c903c3df05347
Parent f6df4cfb
Child 4899d396

Added by Andreas Müller about 2 years ago

ref #7508 fix lazy loading exception for inverseRepresentations

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/initializer/TermBaseAutoInitializer.java
8 8
*/
9 9
package eu.etaxonomy.cdm.persistence.dao.initializer;
10 10

  
11
import eu.etaxonomy.cdm.model.common.CdmBase;
12
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
11 13
import eu.etaxonomy.cdm.model.common.TermBase;
12 14

  
13 15
/**
......
19 21

  
20 22
    @Override
21 23
    public void initialize(TermBase bean) {
22
       beanInitializer.initializeInstance(bean.getRepresentations());
24
        beanInitializer.initializeInstance(bean.getRepresentations());
25
        if (RelationshipTermBase.class.isAssignableFrom(bean.getClass())){
26
            beanInitializer.initializeInstance(CdmBase.deproxy(bean, RelationshipTermBase.class).getInverseRepresentations());
27
        }
23 28
    }
24
    
29

  
25 30
    @Override
26 31
    public String hibernateFetchJoin(Class<?> clazz, String beanAlias) throws Exception{
27
    	return String.format(" LEFT JOIN FETCH %s.representations ", beanAlias); 
32
    	String result = String.format(" LEFT JOIN FETCH %s.representations ", beanAlias);
33
    	if (RelationshipTermBase.class.isAssignableFrom(clazz)){
34
            result += String.format(" LEFT JOIN FETCH %s.inverseRepresentations ", beanAlias);
35
        }
36
    	return result;
28 37
    }
29 38

  
30 39
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)