jpa+hibernate整合达梦数据库(附源码)
生活随笔
收集整理的這篇文章主要介紹了
jpa+hibernate整合达梦数据库(附源码)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
項目整合后的地址
https://gitee.com/gy297879328/jpa_dmhibernate_dm
jar包引入
jpa+hibernate整合達夢數據庫需要引入兩個包
jar包在:數據庫安裝目錄下的drivers/jdbc 匹配相對應版本jar包
pom文件
<dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId><exclusions><exclusion><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId></exclusion></exclusions></dependency><!-- 達夢數據庫依賴 --><dependency><groupId>com.dameng</groupId><artifactId>DmJdbcDriver18</artifactId><version>1.0</version><scope>system</scope><systemPath>${project.basedir}/lib/DmJdbcDriver18.jar</systemPath></dependency><dependency><groupId>com.dameng</groupId><artifactId>DmDialect-for-hibernate5.3</artifactId><version>1.0</version><scope>system</scope><systemPath>${project.basedir}/lib/DmDialect-for-hibernate5.3.jar</systemPath></dependency><dependency><groupId>org.hibernate</groupId><artifactId>hibernate-core</artifactId><version>5.3.18.Final</version></dependency></dependencies>application.properties
spring.datasource.url=jdbc:dm://127.0.0.1:5236 spring.datasource.username=SYSDBA spring.datasource.password=PASSWORD spring.datasource.driver-class-name=dm.jdbc.driver.DmDriverspring.jpa.properties.hibernate.dialect=org.hibernate.dialect.DmDialect spring.jpa.database-platform=org.hibernate.dialect.DmDialect ## 特別重要與spring.jpa.hibernate.ddl-auto=update適配 spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl spring.jpa.properties.hibernate.show_sql=true spring.jpa.hibernate.ddl-auto=update spring.jpa.open-in-view=falsespring.jpa.properties.hibernate.default_schema=SYSDBA spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = falseQ&A
1. spring.jpa.hibernate.ddl-auto=update 參數報錯
報錯截圖
原因
解決辦法
第一種:修改hibernate的生成規則,添加相關的配置spring.jpa.hibernate.naming.physicalstrategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl
第二種:升級hibernate-core的版本為5.6.11.Final
總結
以上是生活随笔為你收集整理的jpa+hibernate整合达梦数据库(附源码)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 函数式编程之Promise的奇幻漂流
- 下一篇: topcoder使用