我想在 spring 查询中使用表名,
但是当我执行它时,我收到以下错误:
"could not extract ResultSet; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
因为当 param 是 String param 时 spring 自动添加引号 "..
@Query(value = "desc :name", nativeQuery = true)
List<RepositoryColumn> getColumnFromRepository(@Param("name") String name);
在其他情况下,我想要 "desc table_name"
而不是 "desc 'table_Name'"
有什么想法吗?
最佳答案
SELECT *
FROM information_schema.columns
WHERE
table_name = :name
尝试同样的另一种方式。您可以选择必要的列,而不是 *
关于java - Spring @Query 删除引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45375370/