Hibernate dialect for MySQL 8?

JavaMysqlHibernate

Java Problem Overview


Is there a Hibernate dialect for MySQL 8? Or should I use the org.hibernate.dialect.MySQL57Dialect that ships with Hibernate? I'm using hibernate 5.2.16

Java Solutions


Solution 1 - Java

MySQL8Dialect(org.hibernate.dialect.MySQL8Dialect) is available in hibernate bundle 5.3.1.Final. You can use:

org.hibernate.dialect.MySQL8Dialect

Solution 2 - Java

yes, For MySQL8, use org.hibernate.dialect.MySQL8Dialect

Solution 3 - Java

If you are using Gradle (e.g. for Grails) just configure:

in application.yml

dataSource:
...
    driverClassName: com.mysql.cj.jdbc.Driver
    dialect: org.hibernate.dialect.MySQL8Dialect
....

in build.gradle

dependencies {
    ...
    runtime 'mysql:mysql-connector-java:8.0.17'
    ...

Pay attention on mysql-connector version and non-deprecated driver class name

Solution 4 - Java

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL8Dialect
spring.jpa.properties.hibernate.dialect.storage_engine=innodb

got from here

Solution 5 - Java

I know this question is a couple of weeks old, but for completeness it appears Hibernate 5.3 does have a MySQL8 dialect

https://docs.jboss.org/hibernate/orm/5.3/javadocs/org/hibernate/dialect/package-summary.html

I have not used it, so I cannot comment on its quality, but the support appears to be there.

Solution 6 - Java

Yes, MySQL8Dialect for MySql 8. In my case I have used MySQL8Dialect for MySql 8 in my spring boot application by following way:

spring.jpa.database-platform=org.hibernate.dialect.MySQL8Dialect  

Solution 7 - Java

Looking over at MySQL 8's release notes, MySQL 8.x has been in development and has only been out for GA since 2018-04-19 (less than a month ago), so I doubt there would be a dialect already made specifically for it.

You can see a list of all hibernate dialects here, and as you can see, there is no MySQL 8 dialect.

MySQLDialect should only be used for MySQL 5 and earlier whereas MySQL57Dialect should be used for MySQL 5.x as well as 8.x for now.

Solution 8 - Java

If you are using SpringBoot

spring:
  jpa:
    hibernate:
      ddl-auto: update
    database-platform: org.hibernate.dialect.MySQL8Dialect

Solution 9 - Java

I had the similar query as I installed MySQL 8 Server and tried to interact with the same using my Spring Boot Application.

But I was unable to do so.

When I explored the Source Code of MySQL5Dialect class, it's documentation clearly mentions that this dialect class has been dedicated to MySQL 5.X versions.

I am not sure whether it supports MySQL 8.X versions.

Thus I would suggest to use MySQL 5.X till an official dialect is released with Hibernate.

Solution 10 - Java

I was able to resolve this by simply adding the configuration below to my application.properties file.

#Hibernate

spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL8Dialect

spring.jpa.driverClassName= com.mysql.cj.jdbc.Driver 

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionunknowView Question on Stackoverflow
Solution 1 - JavaVipin PurohitView Answer on Stackoverflow
Solution 2 - Javaduliu1990View Answer on Stackoverflow
Solution 3 - JavaEugene HozaView Answer on Stackoverflow
Solution 4 - JavaGregory IyamaView Answer on Stackoverflow
Solution 5 - JavaMaxPowerView Answer on Stackoverflow
Solution 6 - JavaTofazzal HossainView Answer on Stackoverflow
Solution 7 - JavaTwiNView Answer on Stackoverflow
Solution 8 - JavaAbderrazzak NejeouiView Answer on Stackoverflow
Solution 9 - JavaPhilip DilipView Answer on Stackoverflow
Solution 10 - JavastephenView Answer on Stackoverflow