Spring CrudRepository findByInventoryIds(Listlt;Longgt; inventoryIdList) - equivalent to IN clause(Spring CrudRepository findByInventoryIds(Listlt;Longgt;inventoryIdList) - 相当于 IN 子句)
问题描述
在 Spring CrudRepository 中,我们是否支持字段的IN 子句"?即类似于以下内容?
In Spring CrudRepository, do we have support for "IN clause" for a field? ie something similar to the following?
findByInventoryIds(List<Long> inventoryIdList)
如果没有这样的支持,可以考虑哪些优雅的选择?为每个 id 触发查询可能不是最优的.
If such support is not available, what elegant options can be considered? Firing queries for each id may not be optimal.
推荐答案
findByInventoryIdIn(List 应该可以解决问题.
HTTP 请求参数格式如下:
The HTTP request parameter format would be like so:
Yes ?id=1,2,3
No ?id=1&id=2&id=3
JPA 存储库关键字的完整列表可以在 当前文档列表.它表明 IsIn 是等价的 - 如果您更喜欢动词以提高可读性 - 而且 JPA 还支持 NotIn 和 IsNotIn.
The complete list of JPA repository keywords can be found in the current documentation listing. It shows that IsIn is equivalent – if you prefer the verb for readability – and that JPA also supports NotIn and IsNotIn.
这篇关于Spring CrudRepository findByInventoryIds(List<Long>inventoryIdList) - 相当于 IN 子句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Spring CrudRepository findByInventoryIds(List<Long>inventoryIdList) - 相当于 IN 子句
基础教程推荐
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
- 将 double 转换为 Int,向下舍入 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- JPA惰性列表上的流 2022-01-01
