Project

General

Profile

Revision d436abeb

IDd436abebb434afdbf0e93af02747ab5520c0e67e
Parent 03c8f07b
Child 05e59317

Added by Katja Luther almost 4 years ago

fix #6061: search for titlecache if abbrev title is empty

View differences:

cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/agent/AgentDaoImpl.java
181 181

  
182 182
        Query query = null;
183 183
        if (pattern != null){
184
            query = session.createQuery("select uuid, id, nomenclaturalTitle, titlecache from " + type.getSimpleName() +" where nomenclaturalTitle like :pattern" + clazzString);
184
            if (clazzString != ""){
185
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() +" WHERE (nomenclaturalTitle LIKE :pattern OR (nomenclaturalTitle IS NULL AND titleCache LIKE :pattern) AND " + clazzString);
186

  
187
            } else{
188
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() +" WHERE nomenclaturalTitle LIKE :pattern");
189

  
190
            }
185 191
            pattern = pattern + "%";
186 192
            pattern = pattern.replace("*", "%");
187 193
            pattern = pattern.replace("?", "_");
188 194
            query.setParameter("pattern", pattern);
189 195
        } else {
190 196
            if (clazzString != ""){
191
                query = session.createQuery("select uuid, id, nomenclaturalTitle, titleCache from " + type.getSimpleName() + " where " + clazzString);
197
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName() + " WHERE " + clazzString);
192 198
            } else{
193
                query = session.createQuery("select uuid, id, nomenclaturalTitle, titleCache from " + type.getSimpleName());
199
                query = session.createQuery("SELECT uuid, id, nomenclaturalTitle, titleCache FROM " + type.getSimpleName());
194 200
            }
195 201
        }
196 202
        if (limit != null){
cdmlib-persistence/src/main/java/eu/etaxonomy/cdm/persistence/dao/hibernate/reference/ReferenceDaoHibernateImpl.java
270 270

  
271 271
        Query query = null;
272 272
        if (pattern != null){
273
            query = session.createQuery("select uuid, id, abbrevTitle, titleCache from " + type.getSimpleName() +" where abbrevTitle like :pattern");
273
            query = session.createQuery("select uuid, id, abbrevTitle, titleCache from " + type.getSimpleName() +" where (abbrevTitle like :pattern OR (abbrevTitle IS NULL AND titleCache like :pattern)) ");
274 274
            pattern = pattern + "%";
275 275
            pattern = pattern.replace("*", "%");
276 276
            pattern = pattern.replace("?", "_");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)