jpa动态sql且分页

1.HQL
@Query("select p.projectMaterial from ProjectMaterialAuthority p where (:projectId is null or p.project.id = :projectId) and (:typeId is null or p.projectMaterial.projectMaterialType.id =:typeId)")
Page<ProjectMaterial> findMaterialByPage(@Param("projectId") Long projectId, @Param("typeId") Long typeId, Pageable page);
2.调用
Long projectId_ = StringUtils.isBlank(projectId) ? null : Long.valueOf(projectId);
Long projectMaterialTypeId_ = StringUtils.isBlank(projectMaterialTypeId) ? null : Long.valueOf(projectMaterialTypeId);
projectMaterialPage = this.authorityRepository.findMaterialByPage(projectId_, projectMaterialTypeId_, PageHelper.generatePageRequest(page, size, sort));


posted on 2020-10-19 14:16  谦虚好学每一天  阅读(388)  评论(0)    收藏  举报

导航