gpt4 book ai didi

java - Spring @Query 删除引号

转载 作者:行者123 更新时间:2023-11-29 10:41:32 24 4
gpt4 key购买 nike


我想在 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com