我喜歡在SortimentRespository中有一個findAll方法,該方法允許排序和分頁,並且可以在當前頁面傳遞一個參數,並將頁面大小和我想要排序的列的名稱不區分大小寫。如何使用Spring Data Rest對數據進行大小寫不敏感?
請求應類似於:
http://localhost:8081/x/rest/sortiments?size=20&page=1
或 http://localhost:8081/x/rest/sortiments?size=20&sort=name,desc&page=1
我想在我的倉庫下面的方法
@Transactional
public interface SortimentRepository extends JpaRepository<Sortiment, RootKey>, SortimentRepositoryCustom {
List<Sortiment> findAll();
// Query 1
Page<Sortiment> findAllIgnoreCase(Pageable pageable);
// Query 2
Page<Sortiment> findAllByOrderByNameAscIgnoreCase(Pageable pageable);
// Query 3
@Query("select s from Sortiment s order by LOWER(s.name)")
Page<Sortiment> findAllOrderByNameIgnoreCase(Pageable p);
}
結果
查詢1: 運行時出錯:org.springframework.beans.factory.BeanCreationException:使用名稱'sortimentRepository'創建bean時出錯:init方法的調用失敗;嵌套異常是org.springframework.data.mapping.PropertyReferenceException:找不到類型Sortiment的屬性!
查詢2: org.springframework.beans.factory.BeanCreationException:創建名爲'sortimentRepository'的bean時出錯:init方法的調用失敗;嵌套異常是org.springframework.data.mapping.PropertyReferenceException:沒有找到類型Sortiment的屬性ignoreCase!
查詢3: 我甚至看不到下鏈接的搜索在HAL瀏覽器這種方法
有誰有一個想法,我怎麼可能實現insenstitive排序的情況下?這將是和是非常好的,如果我有什麼globale因爲幾個庫將需要的findAll不區分大小寫的方法...
重複http://stackoverflow.com/questions/15777638/case-insensitive-sort-using-spring-data – sura2k