Advertisement
Guest User

Untitled

a guest
Dec 21st, 2020
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.61 KB | None | 0 0
  1.     @Query(value = "select resource from ResourceEntity resource "
  2.             + "join resource.resourceFiles files "
  3.             + "join resource.resourceLogs logs "
  4.             + "where resource.id in ("
  5.             + "select distinct resource.id from ResourceEntity resource "
  6.             + "join resource.resourceFiles files "
  7.             + "join resource.resourceLogs logs "
  8.             + "where "
  9.             //filtering
  10.             + "(:name='' or LOWER(resource.name) like CONCAT('%',:name,'%')) "
  11.             + "and (COALESCE(:types) is null or resource.type in (:types)) "
  12.             + "and (:comment='' or LOWER(files.comment) like LOWER(CONCAT('%',:comment,'%'))) "
  13.             + "and (:modifiedBy='' or LOWER(logs.author.firstName) like CONCAT('%',:modifiedBy,'%')  or LOWER(logs.author.lastName) like CONCAT('%',:modifiedBy,'%')) "
  14.             + "and (cast(:startDate as date) is null or logs.date between cast(:startDate as date) and cast(:endDate as date)))" )
  15.            // + "group by (resource.id, logs.author.firstName, logs.date, files.comment)")
  16.     Page<ResourceEntity> filter(Pageable pageable,
  17.                                 @Param("name") @Nullable String name,
  18.                                 @Param("types") @Nullable List<ResourceTypeEnum> types,
  19.                                 @Param("comment") @Nullable String comment,
  20.                                 @Param("modifiedBy") @Nullable String modifiedBy,
  21.                                 @Param("startDate") @Nullable @Temporal Date modifiedOnStartDate,
  22.                                 @Param("endDate") @Nullable @Temporal Date modifiedOnEndDate);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement