code: public <T> Page<T> findByCondition(String whereCondition,
                                          Map<String, Object> conditionParams,
                                          Collection<String> embed,
                                          Pageable pageable,
                                          Class<T> entityClass,
                                          String privilegeKey) {
          String selectSql = format(SELECT_ALL_SQL, entityClass.getSimpleName());
          String countSql = format(COUNT_ALL_SQL, entityClass.getSimpleName());
  
          selectSql += WHERE_SQL + whereCondition;
          countSql += WHERE_SQL + whereCondition;
  
          String permittedCondition = createPermissionCondition(privilegeKey);
          if (StringUtils.isNotBlank(permittedCondition)) {
              selectSql += AND_SQL + "(" + permittedCondition + ")";
              countSql += AND_SQL + "(" + permittedCondition + ")";
          }
  
          TypedQuery<T> selectQuery = createSelectQuery(selectSql, pageable, entityClass);
          if (!CollectionUtils.isEmpty(embed)) {
              selectQuery.setHint(QueryHints.HINT_LOADGRAPH, createEnitityGraph(embed, entityClass));
          }
          TypedQuery<Long> countQuery = createCountQuery(countSql);
  
          conditionParams.forEach((paramName, paramValue) -> {
              selectQuery.setParameter(paramName, paramValue);
              countQuery.setParameter(paramName, paramValue);
          });
  
          log.debug("Executing SQL '{}' with params '{}'", selectQuery, conditionParams);
  
          return execute(countQuery, pageable, selectQuery);
      }
docs: Find permitted entities by parameters with embed graph.
  @param whereCondition the parameters condition
  @param conditionParams the parameters map
  @param embed the embed list
  @param pageable the page info
  @param entityClass the entity class to get
  @param privilegeKey the privilege key for permission lookup
  @param <T> the type of entity
  @return page of permitted entities