首页 > 解决方案 > Spring Data JPA、@NamedQuery 和 Sort 一起

问题描述

我正在尝试同时使用@NamedQuery 和 Sort,但它不起作用,我收到错误“No property * found for type”(如果我使用完全相同的代码而没有 Sort 参数,或者使用 Pageable,那么它工作正常) . 这是我的代码片段。

    @Entity
    @NamedQuery(
            name = "GenerateProductXmlInput.findByFilter",
            query = "select gpxi from GenerateProductXmlInput as gpxi where " +
                    "lower(coalesce(gpxi.shop.name, '')) like lower(concat('%', :filterShopName, '%')) and " +
                    "lower(coalesce(gpxi.locale.language, '')) like lower(concat('%', :filterLocaleLanguage, '%')) and " +
                    "lower(coalesce(gpxi.currency.name, '')) like lower(concat('%', :filterCurrencyName, '%')) and " +
                    "lower(coalesce(gpxi.customerGroup.name, '')) like lower(concat('%', :filterCustomerGroupName, '%'))"
    )
    public class GenerateProductXmlInput implements Serializable {

Page<GenerateProductXmlInput> findByFilter(
        @Param("filterShopName") String filterShopName,
        @Param("filterLocaleLanguage") String filterLocaleLanguage,
        @Param("filterCurrencyName") String filterCurrencyName,
        @Param("filterCustomerGroupName") String filterCustomerGroupName,
        Pageable pageable);

标签: springspring-datanamed-query

解决方案


推荐阅读