I am developing a new application using Spring Boot 2.0.0.M6 and Spring Data JPA. I am using MariaDB v10. Below is my dev properties file.
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:mariadb://localhost:3306/testdb
spring.datasource.username=user
spring.datasource.password=
spring.jpa.show-sql=true
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
org.hibernate.dialect.Dialect=MariaDB53Dialect
spring.jooq.sql-dialect=MariaDB53Dialect
I always get the following output:
Hibernate: create table hibernate_sequence (next_val bigint) engine=MyISAM
I am not able to change the storage engine. All the tables are being created using storage engine MyISAM.
I am able to create tables manually using other storage engines. But for some reason Spring or Hibernate falls back to MyISAM engine only.
With pure Hibernate-Java application, Hibernate uses InnoDB as default.
INFO: HHH000412: Hibernate Core {5.2.11.Final}
Hibernate: create table hibernate_sequence (next_val bigint) engine=InnoDB
Is there any way to override Database storage engine from the Spring Boot properties?
To me it feels like a bug. On Spring (v1.5.8.RELEASE) there is no mention of Storage engine with SQL quaries in the logs and tables are being created using InnoDB.
It鈥檚 not clear why you think this is a bug as you haven鈥檛 shown your configuration for the plain Java/Hibernate case. Perhaps you鈥檙e using a different dialect there or have configured the storage engine. Also, to avoid wasting people鈥檚 time, it鈥檚 better to discuss this in one place. The Stack Overflow question cane first so, to that end, I鈥檓 going to close this. We can re-open it if it turns out that there is a bug in Spring Boot after all.
There are two sample applications at github I uploaded for reference.
Hibernate Application working fine and pick up the dialects properly and uses Hibernate Core 5.2.12.Final
Here is the Spring Boot v2.0.0.M6 application that does not pick up or override and defaults to one dialect MyISAM always.
2017-11-08 11:20:26.850 INFO 17979 --- [ost-startStop-1] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
Hibernate: create table hibernate_sequence (next_val bigint) engine=MyISAM
I used following:
spring.jpa.hibernate.ddl-auto=create-drop
spring.datasource.url=jdbc:mariadb://localhost:3306/testdb
spring.datasource.username=root
spring.datasource.password=
spring.jpa.show-sql=true
spring.datasource.driver-class-name=org.mariadb.jdbc.Driverspring.jooq.sql-dialect=MariaDB53Dialect
org.hibernate.dialect.Dialect=MariaDB53Dialect
dialect=MariaDB53Dialect
org.hibernate.dialect=MariaDB53Dialecthibernate.dialect=MariaDB53
hibernate.dialect=MariaDB53Dialect
hibernate.dialect.storage_engine=InnoDB
dialect.storage_engine=InnoDB
None of the properties is working.
I reverted back to stable version of Spring Boot v1.5.8 and it uses InnoDB as expected.
I just need a right Spring boot property name that can override Database dialect or override storage engine. Is there anything am I missing ?
Thanks
I got the solution by using property:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB53Dialect
I was missing the Spring JPA prefix and fully Qualified name of the Dialect class.
@icewheel Thanks a lot. It works fine.
Most helpful comment
I got the solution by using property:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDB53DialectI was missing the Spring JPA prefix and fully Qualified name of the Dialect class.