gpt4 book ai didi

java - Hibernate 命名策略更改表名

转载 作者:IT老高 更新时间:2023-10-28 13:49:04 25 4
gpt4 key购买 nike

我对 hibernate (5.1 版)命名策略有点困惑——即它改变了我的表名,我想避免这种情况。另外 - spring.jpa.hibernate.naming_strategy 根据 intelij 似乎已被弃用,但我找不到正确配置它的(另一种)方法。

我在application.properties中有如下配置:

spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.current_session_context_class=thread

如前所述,第一个被标记为已弃用。

现在我有了一个实体:

@Entity
@Table(name = "usaUploadTable", schema = "usertable201", catalog = "")
public class UsaUploadTable {
....
}

表名,如 @Table(name = "") usaUploadTable。

现在当我运行我的应用程序时,我得到了

Table 'usertable201.usa_upload_table' doesn't exist

这是正确的 - 它的名称不像 hibernate 是如何改变它的那样。

如何让 hibernate 正确使用我的表名?

编辑:

我也试过

DefaultNamingStrategy
ImprovedNamingStrategy

他们都改变了它

版本:

spring-boot-1.4.0.RELEASE
hibernate 5.1
javax-transaction-api 1.2
hibernate-validator 5.2.4
javassist 3.20

最佳答案

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

它对我有用。这是我正在使用的版本:

Spring Boot (v1.4.2.RELEASE)
Hibernate Core {5.0.11.Final}

关于java - Hibernate 命名策略更改表名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39162976/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com