简单处理方法
直接在 @Column 增加 name参数即可,数据库字段不需要修改
@Column(name = "\"lastValue\"",nullable = false)
@Column(name = "[lastValue]",nullable = false)
@Column(name = "`lastValue`",nullable = false)
<property name="lastValue" type="string">
<column name='"lastValue"' not-null="true"/>
</property>
<property name="lastValue" type="string">
<column name='[lastValue]' not-null="true"/>
</property>
<property name="lastValue" type="string">
<column name='`lastValue`' not-null="true"/>
</property>
从网上找得其他方法都没生效,这里记录下,万一你们用到了可以试试
第一种:自动在执行的sql关键字上添加反引号``
// 配置文件
hibernate.auto_quote_keyword=true
// 同时在spring文件中配置
<prop key="hibernate.auto_quote_keyword">true</prop>
第二种:设置给所有的列名加反引号
hibernate.globally_quoted_identifiers=true
这篇博客介绍了在Hibernate中处理数据库字段名的方法,包括直接在@Column注解中指定name参数,以及通过配置hibernate.auto_quote_keyword和hibernate.globally_quoted_identifiers来自动添加反引号。示例代码展示了不同方式的应用,对于遇到类似问题的开发者提供了参考解决方案。
1123

被折叠的 条评论
为什么被折叠?



