Quarkus: Quarkus Support for MySQL

Created on 2 May 2019  路  13Comments  路  Source: quarkusio/quarkus

Currently there's no support for MySQL on Quarkus. Can this be consider as there are some legacy application currently running on MySQL and need to migrate to Quarkus.

arepersistence good first issue kinnew-feature

Most helpful comment

+1 I agree, we should add such an extension.

All 13 comments

It's the second time someone is asking for that. @gunnarmorling had a Debezium demo using MySQL.

I think it should probably not be too hard as the MariaDB is heavily derived from the MySQL one.

So it would mostly be about copying the jdbc-mariadb extension, the jpa-mariadb integration tests and see if it works.

There's some driver related logic in either the Agroal or the Hibernate ORM extension and mysql will need to be added there too.

If it does not work easily, you might end up with having to add additional GraalVM substitutions and that might not be easy but let's start with the easy part first.

@gsmet the MariaDB driver works seamless with MySQL server by setting the dialect to MySQL as recommended by John Clingan. This properties makes it work for me :
quarkus.hibernate-orm.dialect=org.hibernate.dialect.MySQL5Dialect

@gsmet I'm interested in working on this issue but is it still necessary if it works with the MariaDB extension?

I would still like to see an implementation of a MySQL extension.

  1. reading from @gentletom2004 comment it sound like to have to change one configuration value
    quarkus.hibernate-orm.dialect=org.hibernate.dialect.MySQL5Dialect
    the extension should take care of setting this configuration as default so the developer applying the extension does not have to set this value manually. So a (minimal) code change is required when taking the MariaDB extension as baseline.

  2. It increases visibility that MySQL is acutal supported and works. Not everyone is aware that MariaDB is forked from MySQL and might work.

  3. the MariaDB driver works for MySQL. But the MySQL driver is developed independently and might give a better performance in the long run. Therefore this more specific implementation should be used.

+1 I agree, we should add such an extension.

@Simulant87 are you still keen on working on implementing a MySql extension?

I haven't started implementing anything. I am also not commited to provide long term support for an extension.

@machi1990 if you want to start implementing it, please go ahead. You are not taking anything away from me, what I wanted to do.

However I am interessed in understanding how to build an extension in general. Currently I don't even know where I should start. So maybe I can provide some lines of code or test an early implementation.

hi @Simulant87 - in case you want to give it a shot, don't worry we won't hold you to needing to maintain it as well :)

Building a new extension has indeed a learning curve; we have a guide about it but this could be easy for a simple dependency, or complex if the dependency does lots of unusual things - What needs to be done precisely will depends on what the unusual things are, but don't worry a JDBC driver is typically relatively straight forward (I created all other JDBC driver extensions myself).

The get started in an "easy way", I think indeed creating the MySQL extension is a great idea.

You probably just want to duplicate the same structure as the MariaDB extension: that's a shared pom for the parent, two mave modules, and mention the new artifacts in the various Quarkus parent poms - quite easy if you just search for references to the existing JDBC artifacts and do the same.

You will also need a module for integration tests; this pom will be a little bit more complex by needing to configure a docker image to boot an actual MySQL instance and wire it up to the integration tests.

The code of the extension itself should be trivial - again just look at the one from MariaDB, you probably just need to adapt it slightly.

Regarding the Hibernate Dialect, that's a change for the Hibernate extension: just search for references to the other JDBC drivers.

Thanks!

Regarding the Hibernate Dialect, that's a change for the Hibernate extension: just search for references to the other JDBC drivers.

Adding up to this, to obtain drivers maybe this can be of help https://docs.jboss.org/hibernate/stable/orm/javadocs/org/hibernate/dialect/package-summary.html

I'll take a look.

A quick first step would be to have a quarkus-jdbc-mysql extensions that is just the mariadb extension but also publishes a MySqlBuildItem. The Hibernate extension could listen to it and flip the dialect property.
It would not work for an add having two datasources one with maria and one with mysql but that's a first step that does not requires to make the MySQL driver work on GraalVM. This should be 1hrs of work for someone that knows the extension model I think.

+1 would also like to see full MySQL support

@mbeedub there's a PR open: feel free to test it - https://github.com/quarkusio/quarkus/pull/4067

Was this page helpful?
0 / 5 - 0 ratings