【问题标题】:org.postgresql.util.PSQLException: ERREUR: erreur de syntaxe sur ou près de « $2 » Position : 40org.postgresql.util.PSQLException: ERREUR: erreur de syntaxe sur ou près de « $2 » 位置:40
【发布时间】:2021-09-11 02:55:29
【问题描述】:

我需要帮助!如何在@query nativeSql jpa 中设置列​​。我对此进行了测试,它给出了这样的错误!我认为参数不起作用

@Query(value = "select * from usernotvalid order by ?1 ?2 offset ?3 limit ?4",nativeQuery = true)
public List<User> findAllNotValid(String colonne,String ordre,int debut,int fin);

【问题讨论】:

  • 这是错误:org.postgresql.util.PSQLException: ERREUR: erreur de syntaxe sur ou près de « $2 » Position : 40
  • 这是代码:@Query(value = "select * from usernotvalid order by ?1 ?2 offset ?3 limit ?4",nativeQuery = true) public List findAllNotValid(String Colonne,String ordre,int 首次亮相,int fin);

标签: java spring postgresql spring-boot spring-data-jpa


【解决方案1】:

您需要在 ORDER BY 中的列之间使用逗号

@Query(value = "select * from usernotvalid order by ?1, ?2 offset ?3 limit ?4",nativeQuery = true) 

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-06-16
  • 2021-08-19
  • 1970-01-01
  • 2014-08-13
  • 2017-05-31
相关资源
最近更新 更多