简体   繁体   English

如何配置 Hibernate 使表/列名具有大写和小写字母

[英]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.

相关问题 如何计算字符串中的大写和小写字母? - How to count uppercase and lowercase letters in a string? 修复 SQL 服务器中列名中的大写/小写字母? - Fix uppercase / lowercase letters in column names in SQL Server? 计算字符串的字母(大写和小写) - Counting the letters (uppercase and lowercase) of a string Java正则表达式数字,字母,大写,小写 - java regular expression digits, letters, uppercase, lowercase 如何使Class.forName忽略小写/大写 - How to make Class.forName ignore lowercase/uppercase 如何将每个句子的第一个字母转换为大写,将所有其他字母转换为小写? - How can I convert the first letter of each sentence to uppercase and all other letters to lowercase? 休眠的小写列名称 - hibernate lowercase column names 在Hibernate 5中实现NamingStrategy(将自动生成的列名设置为大写) - Implementing a NamingStrategy in Hibernate 5 (make autogenerated column names UPPERCASE) Spring 引导 JPA 在 TABLE 中插入带有大写名称的 Hibernate - Spring boot JPA insert in TABLE with uppercase name with Hibernate 是否有Lucene Analyzer可以删除所有非字母并将所有大写字母转换为小写字母? - Is there a Lucene Analyzer that removes all the non letters and converts all uppercase to lowercase?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM