Project

General

Profile

« Previous | Next » 

Revision f0cf9026

Added by Katja Luther over 3 years ago

ref #9142: fix getUuidAndAbbrevTitleCache for agents

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java
179 179
    public List<UuidAndTitleCache<AgentBase>> getUuidAndAbbrevTitleCache(Class clazz, Integer limit, String pattern){
180 180
        Session session = getSession();
181 181
        String clazzString = "";
182

  
182 183
        if (clazz == null){
183 184
            clazzString = "";
184 185
        }else if (clazz.equals(Team.class)){
185
            clazzString = "dtype = 'Team'";
186
            clazzString = "dtype like 'Team'";
186 187
        } else if (clazz.equals(Person.class)){
187
            clazzString = "dtype = 'Person'";
188
            clazzString = "dtype like 'Person'";
188 189
        }  else if (clazz.equals(Institution.class)){
189
            clazzString = "dtype = 'Institution'";
190
            clazzString = "dtype like 'Institution'";
190 191
        } else if (clazz.equals(TeamOrPersonBase.class)){
191
            clazzString = "dtype != 'Institution'";
192
            clazzString = "dtype NOT LIKE 'Institution'";
192 193
        }
193 194

  
194 195
        Query query = null;
......
201 202
            if (clazzString != ""){
202 203
                whereClause += " AND " + clazzString;
203 204
            }
204

  
205

  
206
            query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName()  + whereClause);
207

  
208

  
205
            query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName()  + whereClause);
209 206
            pattern = pattern + "%";
210 207
            pattern = pattern.replace("*", "%");
211 208
            pattern = pattern.replace("?", "_");
212 209
            query.setParameter("pattern", pattern);
213 210
        } else {
214 211
            if (clazzString != ""){
215
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() + " WHERE " + clazzString);
212
                query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() + " WHERE " + clazzString);
216 213
            } else{
217
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName());
214
                query = session.createQuery("SELECT DISTINCT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName());
218 215
            }
219 216
        }
220 217
        if (limit != null){

Also available in: Unified diff