首页 文章

Spring的JPA @Param文件名为postgres COPY

提问于
浏览
0

我有以下接口连接到PostgreSQL数据库:

public interface ExampleDAO extends JpaRepository<Example, Integer>
{
    @Modifying
    @Query(value="COPY my_table FROM :filename CSV HEADER", nativeQuery=true)
    public int copyMyTable(@Param("filename") String filename);
}

但是,当我运行它时,我得到了

org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement

我删除 @Param 并硬编码文件名,它工作正常 . 传递的文件名是:

copyMyTable("C:\\path\\to\\my\\file.csv");

我完全不知道这一个!

1 回答

  • 1

    判断from this thread Postgres在这种语句中不支持绑定参数 .

相关问题