Commit 68493d43 authored by Matija Obreza's avatar Matija Obreza

Lowercase like for autocompleters (compatibility with Postgres)

parent 0392db16
......@@ -61,7 +61,7 @@ public interface CountryRepository extends JpaRepository<Country, Long> {
@Query("select distinct c from Country c where c.nameL like :pattern")
List<Country> findWithI18N(@Param("pattern") String pattern);
@Query("select distinct c from Country c where c.code3 like ?1 or c.code2 like ?1 or c.name like ?1 or c.nameL like ?1")
@Query("select distinct c from Country c where lower(c.code3) like lower(?1) or lower(c.code2) like lower(?1) or lower(c.name) like lower(?1) or lower(c.nameL) like lower(?1)")
List<Country> autocomplete(String ac, Pageable pageable);
// @Query("select distinct c from Country c where c.region in ( ?1 )")
......
......@@ -61,7 +61,7 @@ public interface FaoInstituteRepository extends JpaRepository<FaoInstitute, Long
@Query("update FaoInstitute fi set accessionCount=(select count(a) from Accession a where a.institute = :institute ) where fi=:institute")
void updateInstituteAccessionCount(@Param("institute") FaoInstitute institute);
@Query("select distinct fi from FaoInstitute fi where fi.code like ?1 or fi.fullName like ?1 or fi.acronym like ?1 order by fi.accessionCount desc")
@Query("select distinct fi from FaoInstitute fi where lower(fi.code) like lower(?1) or lower(fi.fullName) like lower(?1) or lower(fi.acronym) like lower(?1) order by fi.accessionCount desc")
List<FaoInstitute> autocomplete(String string, Pageable pageable);
}
......@@ -29,19 +29,19 @@ public interface Taxonomy2Repository extends JpaRepository<Taxonomy2, Long> {
@Query("select distinct t.genus from Taxonomy2 t where t.genus like ?1")
List<String> autocompleteGenus(String term, Pageable page);
@Query("select distinct t.genus from Taxonomy2 t join t.cropTaxonomies ct where t.genus like ?1 and ct.crop = ?2")
@Query("select distinct t.genus from Taxonomy2 t join t.cropTaxonomies ct where lower(t.genus) like lower(?1) and ct.crop = ?2")
List<String> autocompleteGenusByCrop(String term, Crop crop, Pageable page);
@Query("select distinct t.species from Taxonomy2 t where t.species like ?1")
@Query("select distinct t.species from Taxonomy2 t where lower(t.species) like lower(?1)")
List<String> autocompleteSpecies(String term, Pageable page);
@Query("select distinct t.species from Taxonomy2 t join t.cropTaxonomies ct where t.species like ?1 and ct.crop = ?2")
@Query("select distinct t.species from Taxonomy2 t join t.cropTaxonomies ct where lower(t.species) like lower(?1) and ct.crop = ?2")
List<String> autocompleteSpeciesByCrop(String term, Crop crop, Pageable page);
@Query("select distinct t.species from Taxonomy2 t where t.species like ?1 and t.genus in (?2)")
@Query("select distinct t.species from Taxonomy2 t where lower(t.species) like lower(?1) and t.genus in (?2)")
List<String> autocompleteSpeciesByGenus(String term, List<String> genus, Pageable page);
@Query("select distinct t.taxonName from Taxonomy2 t where t.taxonName like ?1")
@Query("select distinct t.taxonName from Taxonomy2 t where lower(t.taxonName) like lower(?1)")
List<String> autocompleteTaxonomy(String term, Pageable page);
@Query("select t from Taxonomy2 t where lower(t.genus) = lower(?1) and lower(t.species) = lower(?2) and lower(t.spAuthor) = lower(?3) and lower(t.subtaxa) = lower(?4) and lower(t.subtAuthor) = lower(?5)")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment