我正在努力使订单参数化。最好的就是拥有
... order by :orderColumn :orderDirection ...
是否可以转:
@Query("select * from Document where folderId = :folderId AND documentType = :documentType"
+ " order by created desc limit :limit")
List<Document> findByFolderIdAndDocumentTypeOrderByWithLimit(Long folderId, String documentType,
String orderColumn, Integer limit);
进入:
@Query("select * from Document where folderId = :folderId AND documentType = :documentType"
+ " order by :orderColumn desc limit :limit")
List<Document> findByFolderIdAndDocumentTypeOrderByWithLimit(Long folderId, String documentType,
String orderColumn, Integer limit);
我正在使用 spring-data-jdbc 1.1.3.REELASE 版本。即使只为列名这样做也会对我有很大帮助。