JPA在TABLE中使用Hibernate插入大写字母名称 [英] Spring boot JPA insert in TABLE with uppercase name with Hibernate
本文介绍了JPA在TABLE中使用Hibernate插入大写字母名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个表实体映射为:
@Entity
public class ItemsToRegister implements Serializable {
@Id
@Column(name =ID_ITEM_TO_REGISTER)
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
.....
当我尝试在数据库中插入新记录时,表名称被翻译成小写字母为:items_to_register,但我的表名是ITEMS_TO_REGISTER
如何在不更改MySql配置的情况下修复我的问题? (my.cnf)
我在我的application.properties文件中:
spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
解决方案
在hibernate 5上,它会是
spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
放入 application.properties 文件中。
i have a table entity mapped as :
@Entity
public class ItemsToRegister implements Serializable{
@Id
@Column(name = "ID_ITEM_TO_REGISTER")
@GeneratedValue(strategy = GenerationType.AUTO)
private int id;
.....
When i try to insert new record in database, the table name was translated in lowercase as : items_to_register , but my table name is ITEMS_TO_REGISTER How can i fix my problem without change MySql configuration? (my.cnf)
I have in my application.properties file :
spring.jpa.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.hibernate.naming_strategy = org.hibernate.cfg.ImprovedNamingStrategy
解决方案
On hibernate 5, it would be
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
in your application.properties file.
这篇关于JPA在TABLE中使用Hibernate插入大写字母名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文