Spring CRUD 存储库:是否有 findOneByMaxXYZColumn()? [英] Spring CRUD repository: is there findOneByMaxXYZColumn()?

查看:25
本文介绍了Spring CRUD 存储库:是否有 findOneByMaxXYZColumn()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的要求:

如果 VERSION 列具有最大值,则从表 RETAIN_INFO 中获取一个对象(例如 RetainInfo )

fetch ONE object (e.g RetainInfo ) from table RETAIN_INFO if VERSION column has max value

CRUD 存储库是否支持类似的接口方法

Does CRUD repository support for an interface method like

findOneByMaxRetVersionAndCountry("DEFAULT")

等效的 db2 sql:

Equivalent db2 sql:

select RET_ID, max(ri.RET_VERSION) from RETAIN_INFO ri  where ri. COUNTRY='DEFAULT'  group by RET_ID  fetch first 1 rows only;

  • 此查询选择了一个 ID,但我实际上想要与查询返回的 SINGLE 行相对应的 RetainInfo 对象.
  • 我更喜欢在不使用自定义查询的情况下获得它,即使用 findBy 或 Spring CRUD 支持的其他方法/接口.

    I prefer to get that without using custom query, i.e using findBy or some other method/interface supported by Spring CRUD.

    推荐答案

    Spring Data 不提供选择最大值的表达式.所有支持的查询部分都可以在 Spring 1.2.0.RELEASE 文档中找到:附录 A. 命名空间参考第 182 行 org.springframework.data.repository.query.parser.Part.

    Spring Data doesn't provide an expression to select a max value. All supported query parts could be found in the Spring 1.2.0.RELEASE docs: Appendix A. Namespace reference or line 182 of org.springframework.data.repository.query.parser.Part.

    也可以在 Spring 的 Jira 页面上随意创建功能请求.

    Also feel free to create a feature request at Spring's Jira page.

    这篇关于Spring CRUD 存储库:是否有 findOneByMaxXYZColumn()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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