spring - 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);
解决方案
推荐阅读
- c++ - 如何“突破”套接字中的底层协议
- c++ - Qt静态链接问题:对C++标准库的未定义引用
- tableau-api - 在 Tableau 10.2 中创建常规表
- python - Python 代码在一个编辑器中工作,而不是在另一个编辑器中工作
- react-native - React Navigation 5 - 所有屏幕(如 Twitter)中的堆栈、选项卡和抽屉导航
- google-compute-engine - 使用 gcloud compute ssh - 收到“主机的真实性......无法建立”警告
- c++ - 在不使用动态分配的情况下,C99 复合文字的 C++14 替代方案是什么?
- c# - 如果一个方法在逻辑上必须返回一个值,我是否应该返回一个默认值以满足编译器错误,即并非所有代码路径都返回一个值?
- html - 本地 HTML 文件未在浏览器中加载 CSS 文件
- python - “TypeError: cannot create mpf from d”',当执行“For”结构时