我如何在一个名为hibernate的密钥列名称中加入反引号 [英] How do I put backticks in a column name called key for hibernate
问题描述
我有一个MySQL数据库表,我无法修改但必须插入值。它有一个名为 key
的列,我需要插入它。
现在,我的.hbm.xml文件包含:
< ; property name =key
type =string
column =key/>
生成的插入查询失败。在添加[key]时,生成的SQL现在包含键
,但这也失败了。在检查MYSQL Workbench时,我发现 key
可以工作。
但是,如果我在文件如上所述,当使用[键]时,它回到键。有人可以指导我如何添加 key
并实现所需的插入操作吗?
这里有一个hibernate配置选项。它需要Hibernate 3.5,我不确定你是否使用hbm文件。
在你的hibernate配置集中
hibernate.globally_quoted_identifiers = true
环境配置列表此处
I have a MySQL DB table which I cannot modify but have to insert values into. It has a column called key
which I need to insert into.
Now, my .hbm.xml file has:
<property name="key"
type="string"
column="key" />
The insert query generated hence fails. On adding [key], the generated SQL now contained key
but this also failed. On checking in MYSql Workbench, I found that key
can work.
However, if I change this in the file mentioned above, it reverts to the "key" as when using [key]. Can someone guide me as to how I can add key
and bring about the required insert?
There is a hibernate configuration option for this. It needs Hibernate 3.5 which I'm not sure if you're using based on your use of hbm files.
In your hibernate config set
hibernate.globally_quoted_identifiers=true
List of environment config is here
这篇关于我如何在一个名为hibernate的密钥列名称中加入反引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!