I use JPA to a PostgreSQL DB with my repository
public interface MyRepository extends JpaRepository<...> {
@Query(value = "SELECT * FROM my_table ORDER BY column1", nativeQuery = true)
List<...> find1();
@Query(value = "SELECT * FROM my_table ORDER BY ?1", nativeQuery = true)
List<...> find2(String param);
}
find1()
works fine: all rows are ordered by column1
. But find2("column1")
does not work.
How can I do it? I have to use native queries in any case, therefore I cannot resort to org.springframework.data.domain.Sort
.