[英]How to configure Hibernate to make table/column name with uppercase AND lowercase letters
I have to use table and column names in my Postgres that contain uppercase and lowercase letters .我必须在我的 Postgres 中使用包含大写和小写字母的表名和列名。 For example OrgInfo
例如OrgInfo
I would like to create such tables and columns using Hibernate .我想使用Hibernate创建这样的表和列。 If I use standard approach:如果我使用标准方法:
@Entity
@Table(name = "OrgInfo")
then I receive the table with the name "org_info".然后我收到名为“org_info”的表格。
How I can configure Hibernate to create tables and columns with exact given names including uppercase and lowercase letters?我如何配置 Hibernate 以创建具有确切给定名称(包括大写和小写字母)的表和列?
I have tried to use我试过使用
@Entity
@Table(name = "\"OrgInfo\"")
with no effect.没有效果。
Also I use Spring Boot and have tried to configure like this:我也使用 Spring Boot 并尝试这样配置:
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultNamingStrategy OR spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.DefaultNamingStrategy OR spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
Try to configure Hibernate "physical-strategy" in your configuration file as follows: 尝试在配置文件中配置Hibernate的“物理策略”,如下所示:
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
尝试这个:
@Entity @Table(name = "\"OrgInfo\"")
The working solution is to use both parts: 可行的解决方案是同时使用两个部分:
@Entity
@Table(name = "\"OrgInfo\"")
and 和
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.hibernate.naming.physical-strategy = org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
application.yml version of the answer by @Sachin: @Sachin 的答案的 application.yml 版本:
hibernate:
physical_naming_strategy: 'org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.