1

Using Spring data JPA, trying to create a generic method to upload csv data to database using Load Data mysql. The below code is my attempt. The problem is, the second parameter tablename is getting replaced with quotes. Eg: LOAD DATA LOCAL INFILE Client.csv INTO TABLE 'Client' FIELDS

Any idea on how to overcome this ??

@NoRepositoryBean public interface CustomJpaRepository<T, ID extends Serializable> extends JpaRepository<T, ID> {

@Query(value = "LOAD DATA LOCAL INFILE :filepath INTO TABLE :tablename FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n'", nativeQuery = true)
public void bulkInsertUsingCLI(@Param("filepath") String filepath, @Param("tablename") String tablename);

}
CinCout
  • 9,486
  • 12
  • 49
  • 67
Naren Kannan
  • 21
  • 1
  • 6

0 Answers0