-2

If my table consists of col1, col2, col3 ....

Then if I have to get all the distinct values of col3( decided on runtime)

1 Answers1

0
  1. Spring Data does not provide any data calculations - it just translate declarative method invocation/JPQL query to SQL (If you use relational DB under Spring Data). So distinct query will be translated to SQL DISTINCT operator.
  2. You can use Criteria API if you need distinct result set on DB level by dynamically assigned field. You can use Reflection API and pass Field object which will be used in Criteria query builder.
  3. Another way is to invoke findAll() on your Spring Data repository to retrieve all table records, and then remove duplicate by concrete field in your java code.