Project

General

Profile

« Previous | Next » 

Revision 9dc896c9

Added by Andreas Müller almost 7 years ago

fix #6368 rename table and class TaxonNameBase

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/initializer/TitleAndNameCacheAutoInitializer.java
10 10

  
11 11
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
12 12
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
13
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
13
import eu.etaxonomy.cdm.model.name.TaxonName;
14 14
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
15 15

  
16 16
/**
......
30 30
public class TitleAndNameCacheAutoInitializer extends AutoPropertyInitializer<IdentifiableEntity<?>> {
31 31

  
32 32

  
33
    /* (non-Javadoc)
34
     * @see eu.etaxonomy.cdm.persistence.dao.BeanAutoInitializer#initialize(eu.etaxonomy.cdm.model.common.CdmBase)
35
     */
36 33
    @Override
37 34
    public void initialize(IdentifiableEntity<?> bean) {
38 35

  
39 36
        bean = HibernateProxyHelper.deproxy(bean, IdentifiableEntity.class);
40 37
        // we will implement a bit of redundancy here in order
41 38
        // to avoid too much casting
42
        if(bean instanceof TaxonNameBase){
39
        if(bean instanceof TaxonName){
43 40
            // ---> NonViralName
44
            TaxonNameBase n = (TaxonNameBase)bean;
41
            TaxonName n = (TaxonName)bean;
45 42
            if(!n.isProtectedFullTitleCache())  {
46 43
                n.getFullTitleCache();
47 44
            } else if(!bean.isProtectedTitleCache()){
......
63 60
                 * explicitly in order to trigger the cascade. Otherwise a
64 61
                 * LazyInitializationException can occur:
65 62
                 *   > failed to lazily initialize a collection of role:
66
                 *   > eu.etaxonomy.cdm.model.name.TaxonNameBase.relationsToThisName
63
                 *   > eu.etaxonomy.cdm.model.name.TaxonName.relationsToThisName
67 64
                 * --------------------------------------------
68 65
                 * according code snipped from cachestrategy:
69 66
                 *  if (nameCache == null){
......
73 70
                 */
74 71
                n.getTaggedName();
75 72
            }
76
        } else if(bean instanceof TaxonNameBase) {
77
             // ---> TaxonNameBase
78
            TaxonNameBase<?,?> n = (TaxonNameBase<?,?>)bean;
73
        } else if(bean instanceof TaxonName) {
74
             // ---> TaxonName
75
            TaxonName n = (TaxonName<?,?>)bean;
79 76
            if(!n.isProtectedFullTitleCache())  {
80 77
                n.getFullTitleCache();
81 78
            } else if(!bean.isProtectedTitleCache()){
......
93 90
    public String hibernateFetchJoin(Class<?> clazz, String beanAlias) throws Exception{
94 91

  
95 92
        String result = "";
96
        if (TaxonNameBase.class.isAssignableFrom(clazz)){
93
        if (TaxonName.class.isAssignableFrom(clazz)){
97 94
            result += String.format(" LEFT JOIN FETCH %s.rank ", beanAlias);
98 95
            result += String.format(" LEFT JOIN FETCH %s.relationsToThisName relTo LEFT JOIN FETCH relTo.relatedFrom ", beanAlias);
99 96
            result += String.format(" LEFT JOIN FETCH %s.combinationAuthorship ", beanAlias);
......
108 105
        }
109 106

  
110 107
        // throw an exception since LEFT JOIN FETCH is not really working for titleCaches
111
        // TODO test if the LEFT JOIN FETCHes are at least working for TaxonNameBase and NonViralName
108
        // TODO test if the LEFT JOIN FETCHes are at least working for TaxonName and NonViralName
112 109
        throw new Exception();
113 110

  
114 111
//        return result;

Also available in: Unified diff