Project

General

Profile

Download (1.5 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 EDIT
3
* European Distributed Institute of Taxonomy
4
* http://www.e-taxonomy.eu
5
*
6
* The contents of this file are subject to the Mozilla Public License Version 1.1
7
* See LICENSE.TXT at the top of this package for the full license terms.
8
*/
9
package eu.etaxonomy.cdm.persistence.dao.initializer;
10

    
11
import java.util.Optional;
12

    
13
import eu.etaxonomy.cdm.model.common.CdmBase;
14
import eu.etaxonomy.cdm.model.common.RelationshipTermBase;
15
import eu.etaxonomy.cdm.model.term.TermBase;
16

    
17
/**
18
 * Note: Probably not really needed as we are currently loading representations and inverse representations eager.
19
 *
20
 * @author a.kohlbecker
21
 * @since 30.07.2010
22
 */
23
public class TermBaseAutoInitializer extends AutoPropertyInitializer<TermBase> {
24

    
25
    @Override
26
    public void initialize(TermBase bean) {
27
        beanInitializer.initializeInstance(bean.getRepresentations());
28
        if (RelationshipTermBase.class.isAssignableFrom(bean.getClass())){
29
            beanInitializer.initializeInstance(CdmBase.deproxy(bean, RelationshipTermBase.class).getInverseRepresentations());
30
        }
31
    }
32

    
33
    @Override
34
    public Optional<String> hibernateFetchJoin(Class<?> clazz, String beanAlias){
35
    	String result = String.format(" LEFT JOIN FETCH %s.representations ", beanAlias);
36
    	if (RelationshipTermBase.class.isAssignableFrom(clazz)){
37
            result += String.format(" LEFT JOIN FETCH %s.inverseRepresentations ", beanAlias);
38
        }
39
    	return Optional.of(result);
40
    }
41

    
42
}
(13-13/15)