具有最大限制和条件的 Spring 数据查询 [英] Spring data query with max limit and condition

查看:35
本文介绍了具有最大限制和条件的 Spring 数据查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得年份最高并有特定个人姓名的项目.我正在尝试:

I want to get the item with the highest year and has a particular personal name. I'm trying this:

Foo findTopByOrderByYearDesc();

这很好用,问题是当我添加一个新参数来过滤结果时

This work great, the problem is when I add a new param to filter results

Foo findTopByOrderByYearDescAndPersonName(@Param("person.name") final String name);

但我收到此错误:

没有找到 Foo 类型的属性和人名!

No property andPersonName found for type Foo!

我也试过这个,但我得到了同样的错误:

I try this too but I get de same error:

Foo findTopByOrderByYearDescByPersonName(@Param("person.name") final String name);

推荐答案

您应该使用以下内容:

Foo findTopByPersonNameOrderByYearDesc(@Param("person.name") final String name);

第一个 'by' keyqord 用作分隔符 见这里

The first 'by' keyqord works as a delimiter see here

这篇关于具有最大限制和条件的 Spring 数据查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆