Project

General

Profile

Revision 38b82688

ID38b82688ed620438a21acd5405917acd1c5fe8f0
Parent 6a70de90
Child f742ce44

Added by Katja Luther about 4 years ago

fix #6061: search in titlecache and nomenclatural titleCache in getUuidAndAbbrevTitleCache

View differences:

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

  
182 182
        Query query = null;
183
        String whereClause = " WHERE ";
183 184
        if (pattern != null){
185
            whereClause += "nomenclaturalTitle LIKE :pattern";
186
            if (pattern.startsWith("*")){
187
                whereClause += " OR titleCache LIKE :pattern";
188
            }
184 189
            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);
190
                whereClause += " AND " + clazzString;
191
            }
192

  
193

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

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

  
190
            }
191 197
            pattern = pattern + "%";
192 198
            pattern = pattern.replace("*", "%");
193 199
            pattern = pattern.replace("?", "_");
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, abbrevTitleCache, titleCache from " + type.getSimpleName() +" where abbrevTitleCache like :pattern  ");
273
            if (pattern.startsWith("*")){
274
                query = session.createQuery("select uuid, id, abbrevTitleCache, titleCache from " + type.getSimpleName() +" where abbrevTitleCache like :pattern OR titleCache like :pattern ");
275
            }else{
276
                query = session.createQuery("select uuid, id, abbrevTitleCache, titleCache from " + type.getSimpleName() +" where abbrevTitleCache like :pattern  ");
277
            }
274 278
            pattern = pattern + "%";
275 279
            pattern = pattern.replace("*", "%");
276 280
            pattern = pattern.replace("?", "_");

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)