Reputation: 13644
this is my config:
spring.jpa:
hibernate:
ddl-auto: update
connection:
charset: utf8
useUnicode: true
properties.hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Based on what I found in docs and SO it should work but still new tables are create with MyISAM instead of InnoDB.
What is wrong in my config?
Upvotes: 5
Views: 12156
Reputation: 21
The prefered method is to use spring.jpa.database-platform
. It works across every provider supported by spring-boot and JPA.
properties.hibernate...
is for setting hibernate specific configurations.
Setting property hibernate.dialect
"directly" (under spring.jpa.properties) is more like a last-resort method for special cases, and locks you more tightly with Hibernate.
Try this:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://<host>[:<port>]/<database>
username:
password:
jpa:
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
hibernate.ddl-auto: validate
show-sql: false
format-sql: false
properties.hibernate.jdbc.lob.non_contextual_creation: true
properties.hibernate.ejb.event.pre-insert: AuditableJpaInterceptor
properties.hibernate.ejb.event.pre-update: AuditableJpaInterceptor
Upvotes: 0
Reputation: 71
Provide below change in your application.yml
spring.datasource: url: jdbc:mysql://?verifyServerCertificate=false&useSSL=true&requireSSL=false username: password:
spring.jpa: properties: hibernate: dialect: org.hibernate.dialect.MySQLDialect
It will work :)
Upvotes: 0
Reputation: 2349
The property for setting the dialect is actually spring.jpa.properties.hibernate.dialect
Try this:
spring.jpa:
hibernate:
connection:
charset: utf8
useUnicode: true
ddl-auto: update
properties.hibernate.dialect: org.hibernate.dialect.MySQL5InnoDBDialect
Spring boot sample for reference
Upvotes: 8