spring - 在spring boot中过滤数据
问题描述
不知道这是否可能,但我想调用我的数据并对其进行过滤,因此例如通知类型将是 1 或 2,然后给我所有的 1 和 2 My Model
public class Notifications {
@Id
private String id;
private String notificationMsg;
private String notificationType;
private Date createdDate = new Date();
//Get all Notification by type
@RequestMapping(value = "/all/{notificationType}", method = RequestMethod.GET)
public List<Notifications> getAllByNotificationType(@PathVariable("notificationType") String notificationType) {
List<Notifications> notifications= this.notificationRepository.findByNotificationType(notificationType);
return user;
}
或者我应该添加到模型中并创建一个这样的界面
List<Notifications> findByNumber1ORNumber2ORNumber3(String Number1,String Number2,String Number3);
解决方案
您可以使用in
子句:
https://javadeveloperzone.com/spring/spring-jpa-query-in-clause-example/
List<Employee> findByEmployeeNameIn(List<String> names)
;
推荐阅读
- android - CTRL+SPACE 不显示布局
- azure - 将 WAR 文件部署到 Azure Web 服务时,它未显示在服务器 URL 中,但管道已成功运行
- python - 关于在 Jupyter 上使用 Pandas 绘制多种颜色的 Dataframe 的问题
- google-chrome-extension - 在 chrome 扩展程序中获取当前标签页 url
- mongodb - 如何使用聚合管道插入不存在的文档?
- r - 在 R 中添加包含具有固定参考值的差异的新列
- node.js - 我无法在 Windows 10 上重新安装 node.js
- java - 如何将 JSON 请求解析为 FlightOfferSearch[] 对象?
- c# - 使用 TrackDependency 是获取业务逻辑层 .NET 库类的指标的正确方法吗?
- sql - 在 Oracle Apex 中显示服务器端条件取决于页面项值的按钮?