如何在Spring中过滤数据

时间:2019-02-20 12:31:22

标签: spring postgresql

我有一个返回列表的方法,如何在spring存储库或sql查询级别过滤此数据,我需要过滤后的数据才能到达此方法

public List<Mark> getMarksByUser(){
List<Mark> marks = markService.getMarksByUser(AuthenticationController.selfUserName());

}

例如,您可以在标记的createDate字段上方显示过滤器示例

public class Mark extends BaseEntity<Integer> {
private String text;
private String sku;
private Date dateCreated;

1 个答案:

答案 0 :(得分:0)

@Query("SELECT mark FROM Mark mark where mark.dateCreated = :dateCreated AND mark.deleted = :deleted")
List<Mark> findByDateCreatedAndDeleted(@Param("dateCreated") Date dateCreated,
                                                @Param("deleted") Boolean deleted);