I found an example [1]

public interface EmployeeRepository extends CrudRepository<Employee, Long> {
  @Query("SELECT e FROM Employee e WHERE e.dept = :dept AND "
          + "(SELECT COUNT(DISTINCT e2.salary) FROM Employee e2 "
          + "WHERE e.salary < e2.salary AND e2.dept = :dept) < :topSalNum "
          + "ORDER BY e.salary DESC")
  List<Employee> findByDeptTopNSalaries(@Param("topSalNum") long
topSalaryNum, @Param("dept") String dept);
}

[1] 
https://www.logicbig.com/tutorials/spring-framework/spring-data/query-named-parameters.html

чт, 19 дек. 2019 г. в 14:53, Ivan Pavlukhin <[email protected]>:
>
> Single "?" placeholder assumes single value replacement. Query "SELECT
> * FROM Person WHERE salary IN (?)" returns empty result set because it
> is the same as "SELECT * FROM Person WHERE salary = ?". But there is
> no salary which is equal to any List<Double>. Spreading List (and
> other collections) into multiple parameters in query was possible with
> NamedParameteJdbcTemplace (by using placeholder ":parName" instead of
> "?"). There could be something similar in Spring data.
>
> чт, 19 дек. 2019 г. в 14:29, shishkovilja <[email protected]>:
> >
> > Oh, sorry, it seems to be my mistake, in this case no exception occurs, but
> > resulting iterator is empty
> >
> >
> >
> > --
> > Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>
>
>
> --
> Best regards,
> Ivan Pavlukhin



-- 
Best regards,
Ivan Pavlukhin

Reply via email to