When I'm trying to select table by parameter:
@Repository
public interface IParametersRepository extends JpaRepository<Parameters, Long> {
@Query(value = "SELECT param_def_id FROM :param", nativeQuery = true)
Optional<List<String>> GetParameterDefIDs(@Param("param") String param);
}
I get invalid table name error:
Hibernate: SELECT param_def_id FROM ?
2021-03-18 09:12:20.734 TRACE 980 --- [nio-8080-exec-2] o.h.type.descriptor.sql.BasicBinder :
binding parameter [1] as [VARCHAR] - [PARAM_APP]
2021-03-18 09:12:20.787 WARN 980 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper :
SQL Error: 903, SQLState: 42000
2021-03-18 09:12:20.787 ERROR 980 --- [nio-8080-exec-2] o.h.engine.jdbc.spi.SqlExceptionHelper :
ORA-00903: invalid table name
But when the query is written manually I get all data from db.
@Query(value = "SELECT param_def_id FROM PARAM_APP", nativeQuery = true)
Optional<List<String>> GetParameterDefIDs(@Param("param") String param);
This is my request: localhost:8080/api/app/parameters?param=PARAM_APP