`

80. Hibernate 5.0命名策略使用naming-strategy 不起作用【从零开始学Spring Boot】

阅读更多

 

【原创文章,转载请注明出处】

       事情的起因:一不小心从1.3.3升级到了1.4.0版本,结果就碰到了各种悲催的事情了,好吧,Hibernate5.0的新特性就是其中一个坑,我们会发现我们配置的naming-strategy不生效了。那怎么办呢?请差此文,此文应该是可以解决您的困惑的。

 

       我们先看看Hibernate原文怎么说的:

       Hibernate 5

       Hibernate 5.1 is now used as the default JPA persistence provider. If you are upgrading from Spring Boot 1.3 you will be moving from Hibernate 4.3 to Hibernate 5.1. Please refer to Hibernate migration documentation for general upgrade instructions. In addition you should be aware of the following:

SpringNamingStrategy is no longer used as Hibernate 5.1 has removed support for the oldNamingStrategy interface. A new SpringPhysicalNamingStrategy is now auto-configured which is used in combination with Hibernate’s default ImplicitNamingStrategy. This should be very close to (if not identical) to Spring Boot 1.3 defaults, however, you should check your Database schema is correct when upgrading.

If you were already using Hibernate 5 before upgrading, you may be using Hibernate’s 5 default. If you want to restore them after the upgrade, set this property in your configuration:

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

 

     

 

  上面这么信息,其实就是想表达如果想升级Hibernate5.1的话,那么之前的

hibernate.ejb.naming_strategy将不再被支持,而是被替换成了两个属性:

hibernate.physical_naming_strategy

hibernate.implicit_naming_strategy

 

这两个属性都是干嘛的呢?

 

       对于 implicit_naming_strategy Hibernate官方有这么一句话:

used whenever a table or column is not explicitly named to determine the name to use

       implicit naming strategy:隐式命名策略,使用此属性当我们使用的表或列没有明确指定一个使用的名称 。

    

   对于 physical_naming_strategy Hibernate官方有这么一句话:

used to convert a "logical name" (either implicit or explicit) name of a table or column into a physical name (e.g. following corporate naming guidelines)

       physical naming strategy:物理命名策略,用于转换“逻辑名称”(隐式或显式)的表或列成一个物理名称。

      

 

  1.     之后的才是重点哦,对于physical_naming_strategy有两个常用的配置:

org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy

org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

       对于PhysicalNamingStrategyStandardImplDefaultNamingStrategy的效果;对于SpringPhysicalNamingStrategy  

ImprovedNamingStrategy的效果。

 

       另外一个属性,好吧,其实我也不是很明白具体是怎么使用,以及这两个属性怎么配合使用,什么场景下出现什么特殊的效果。有知道的不吝赐教,在此谢过。

 

   à悟空学院:https://t.cn/Rg3fKJD

学院中有Spring Boot相关的课程!点击「阅读原文」进行查看!

SpringBoot视频:http://t.cn/A6ZagYTi

Spring Cloud视频:http://t.cn/A6ZagxSR

SpringBoot Shiro视频:http://t.cn/A6Zag7IV

SpringBoot交流平台:https://t.cn/R3QDhU0

SpringData和JPA视频:http://t.cn/A6Zad1OH

SpringSecurity5.0视频:http://t.cn/A6ZadMBe

Sharding-JDBC分库分表实战http://t.cn/A6ZarrqS

分布式事务解决方案「手写代码」:http://t.cn/A6ZaBnIr

 

分享到:
评论
3 楼 秋风凉 2018-03-06  
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl


spring.jpa.hibernate.naming.implicit -strategy=org.hibernate.boot.model.naming.SpringPhysicalNamingStrategy  
2 楼 林祥纤 2016-10-12  
k88520 写道
请问博主这个为什么没有放源码呢


这个是理论知识,自己配置下,试试就知道好不好使了。
1 楼 k88520 2016-10-11  
请问博主这个为什么没有放源码呢

相关推荐

    util-naming-2.0.1-450.jar

    util-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450.jarutil-naming-2.0.1-450....

    nacos-naming-2.0.4.RELEASE-API文档-中文版.zip

    赠送jar包:nacos-naming-2.0.4.RELEASE.jar; 赠送原API文档:nacos-naming-2.0.4.RELEASE-javadoc.jar; 赠送源代码:nacos-naming-2.0.4.RELEASE-sources.jar; 赠送Maven依赖信息文件:nacos-naming-2.0.4....

    spring的配置文件范例

    spring 配置文件

    nacos-naming-2.0.4.RELEASE-API文档-中英对照版.zip

    赠送jar包:nacos-naming-2.0.4.RELEASE.jar; 赠送原API文档:nacos-naming-2.0.4.RELEASE-javadoc.jar; 赠送源代码:nacos-naming-2.0.4.RELEASE-sources.jar; 赠送Maven依赖信息文件:nacos-naming-2.0.4....

    spring-boot-reference.pdf

    Spring Boot Documentation 1. About the Documentation 2. Getting Help 3. First Steps 4. Working with Spring Boot 5. Learning about Spring Boot Features 6. Moving to Production 7. Advanced Topics II. ...

    jndi naming-factory-dbcp.jar

    naming-factory-dbcp.jar

    开发用jar包合集

    jetty-naming-6.1.25.jar jetty-plus-6.1.25.jar jetty-util-6.1.25.jar jna-3.2.7.jar jna-4.4.0.jar jna-platform-4.4.0.jar jsch-0.1.51.jar json-lib-2.2.2-jdk15.jar json-lib-2.4-jdk15.jar jsp-2.1...

    Spring boot基础搭建

    spring.jpa.hibernate.naming-strategy=org.hibernate.cfg.ImprovedNamingStrategy # Use spring.jpa.properties.* for Hibernate specific settings spring.jpa.properties.hibernate.dialect=org.hibernate....

    nacos-server-1.2.1.tar.gz 和 nacos-server-1.2.1.zip

    英文全称 Dynamic Naming and Configuration Service,Na 为 Naming/NameServer 即注册中心,co 为 Configuration 即配置中心,Service 是指该注册/配置中心都是以服务为核心。服务(Service)是 Nacos 世界的一等...

    struts spring lib

    naming-factory.jar poi-3.0-alpha2-20060616.jar poi-contrib-3.0-alpha2-20060616.jar poi-scratchpad-3.0-alpha2-20060616.jar spring-aop.jar spring-test.jar spring-webmvc-struts.jar spring-webmvc.jar ...

    naming-resources.jar

    naming-resources.jar

    spring boot集成ldap

    在IT行业中,Spring Boot是一个非常流行的微服务框架,它简化了Spring应用的初始化和配置过程。而LDAP(Lightweight Directory Access Protocol)则是一种用于存储和检索分布式目录信息的标准协议,常用于用户身份...

    EurekaLog_7.5.0.0_Enterprise

    EurekaLog 7.2 Hotfix 5 (7.2.5.0), 1-July-2015 1)....Added: HKCU\Software\EurekaLab\Viewer\4.0\UI\Statuses registry key to allow status customizations in Viewer 2)....Added: "Disable hang detection ...

    naming-factory.jar

    naming-factory.jar

    gulp-check-file-naming-convention:检查文件名是否符合命名约定

    check-file-naming-convention插件 用法 首先,安装gulp-check-file-naming-convention作为开发依赖项: npm install --save-dev gulp-check-file-naming-convention 然后,将其添加到您的gulpfile.js : var ...

    Hibernate5.0用户手册中文版本.docx

    根据提供的文档信息,我们可以归纳出一系列关于Hibernate 5.0的关键知识点。这些知识点涵盖了Hibernate的基本概念、体系架构、域模型的设计、启动流程、持久化上下文的管理、数据库访问方式、事务与并发控制机制、...

    Python库 | Pyro4-4.42-py2.py3-none-any.whl

    2. **命名服务(Naming Service)**: Pyro4提供了一个简单的DNS替代方案,帮助定位和管理远程对象的URI(统一资源标识符)。 3. **事件(Events)**: Pyro4支持发布/订阅模型,允许你广播消息到多个接收者。 4. **...

    nacos-server-2.2.0.tar.gz

    一旦检测到不健康的实例,会从服务列表中剔除,避免请求被转发到异常实例。 4. **多语言支持**:Nacos 支持多种开发语言,包括 Java、Go、Python、Node.js 等,使得它能够广泛地应用于跨语言的微服务架构中。 5. *...

    sprngboot基本信息ppt

    spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy ``` #### 五、Spring Boot 与传统 Java 应用服务器的区别 虽然 Spring Boot 可以将 ...

Global site tag (gtag.js) - Google Analytics