I have the following interface which is connected to a PostgreSQL database:
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);
}
But when I run it I get
org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute statement; SQL [n/a]; nested exception is org.hibernate.exception.SQLGrammarException: could not execute statement
I remove the @Param and hardcode the filename in and it works fine. The filename passed is:
copyMyTable("C:\\path\\to\\my\\file.csv");
I am totally at a loss on this one!