Spring @Query删除报价 [英] Spring @Query Remove Quote
本文介绍了Spring @Query删除报价的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在春季查询中使用表格名称,但是当我执行它时,出现以下错误:
I want to use a table name in spring query,
but when I execute it I got this following error:
"could not extract ResultSet; SQL [n/a]; nested exception is
org.hibernate.exception.SQLGrammarException: could not extract ResultSet"
因为当param是String param时,spring会自动加引号"..
Because spring add automatically quote " when param is a String param ..
@Query(value = "desc :name", nativeQuery = true)
List<RepositoryColumn> getColumnFromRepository(@Param("name") String name);
在其他情况下,我需要"desc table_name"
,而不是"desc'table_Name'"
In other case I want "desc table_name"
and not "desc 'table_Name'"
有什么主意吗?
推荐答案
SELECT *
FROM information_schema.columns
WHERE
table_name = :name
以其他方式尝试.您可以选择必要的列代替 *
Try the same another way. Instead of *
you can choose necessary columns
这篇关于Spring @Query删除报价的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文