我有以下连接到 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");
我对这个完全不知所措!