Closed tmulle closed 3 months ago
/cc @DavideD (hibernate-reactive), @gavinking (hibernate-reactive), @gsmet (hibernate-orm), @mswatosh (db2), @yrodiere (hibernate-orm)
I will give it a look
I don't know why, but Hibernate ORM reads the wrong database version when picking the dialect.
@tmulle, as a workaround, you can set the following property in the application.properties
:
quarkus.datasource.db-version=10.11
@yrodiere, any idea?
@DavideD thanks that workaround does work. I will leave that in-place until an official fix is ready.
I don't know why, but Hibernate ORM reads the wrong database version when picking the dialect.
What do you mean, "reads the wrong database version"? There is nothing to read, the dialect is picked offline, at build time.
Generally when db-version
is not set, we pick Hibernate ORM's earliest supported version; in the case of MariaDB, it's 10.4, though for history reasons, Quarkus will default to 10.6 instead.
@tmulle, as a workaround, you can set the following property in the
application.properties
:quarkus.datasource.db-version=10.11
This is not a workaround, this is the proper solution to this problem.
See https://quarkus.io/guides/hibernate-orm#hibernate-dialect-supported-databases:
By default, the dialect is configured to target the minimum supported version of the database. In order for Hibernate ORM to generate more efficient SQL, to avoid workarounds and to take advantage of more database features, you can set the database version explicitly:
quarkus.datasource.db-kind = postgresql quarkus.datasource.db-version = 14.0 quarkus.datasource.username = hibernate quarkus.datasource.password = hibernate quarkus.datasource.jdbc.url = jdbc:postgresql://localhost:5432/hibernate_db
As a rule, the version set here should be as high as possible, but must be lower than or equal to the version of any database your application will connect to.
Closing this issue, as this is not a bug: you really should configure your DB version if you expect features beyond what the oldest supported version of your database can offer.
What do you mean, "reads the wrong database version"? There is nothing to read, the dialect is picked offline, at build time.
Ok, I get it and I didn't read the whole documentation, so I didn't know this was the expected behaviour.
But it's different than what happens with regular Hibernate ORM. So, unless somebody has read the documentation in detail, there's nothing that indicates that this is the correct behaviour. Not to mention that somebody might decide to switch database and not realizing that the new one is not supported.
It would be nice to have a message at start up containing the selected dialect with the version and a note that it's not supported so the default version will be used instead.
It would be nice to have a message at start up containing the selected dialect with the version and a note that it's not supported so the default version will be used instead.
I guess I'm not the only one that thinks this is important info to have: https://github.com/quarkusio/quarkus/issues/40922
It would be nice to have a message at start up containing the selected dialect with the version and a note that it's not supported so the default version will be used instead.
The default version is used for supported dialects too.
This is not what the documentation says, though:
For supported databases, the Hibernate ORM dialect does not need to be set explicitly: it is selected automatically based on the datasource.
Ok... I guess the dialect is selected but the correct version isn't?
Am I the only one that thinks a bit more clarity would be nice?
Ok... I guess the dialect is selected but the correct version isn't?
Yes.
Am I the only one that thinks a bit more clarity would be nice?
You're the first to report this particular problem, yes.
Feel free to send a PR if you have an idea how to improve the wording.
Describe the bug
According to all the documentation I can find with Quarkus and Hibernate 6, the UUID type should be supported for MariaDB 10.11.
Yet, when I attempt to use the
import.sql
file to add some test data, startup fails with an error.It looks like the Hibernate table generator is still using the
BINARY(16)
column type instead of theUUID
type available since MariaDB 10.7.Links: https://mariadb.com/kb/en/uuid/ https://www.baeldung.com/java-hibernate-uuid-primary-key
Sample project, very simple one table and import.sql
https://github.com/tmulle/quarkus-mariadb-uuidtest
I've tried with and without the
@GeneratedValue(strategy = GenerationType.UUID)
on the id field and still same thing. The table gets generated as aBINARY(16)
in mariadb 10.11 (Dev Services).This is the output:
Expected behavior
I would think the generator would use the
UUID
type instead of the oldBINARY(16)
type since it is now using Hibernate 6.x?Actual behavior
No response
How to Reproduce?
No response
Output of
uname -a
orver
No response
Output of
java -version
JDK 17
Quarkus version or git rev
3.11
Build tool (ie. output of
mvnw --version
orgradlew --version
)maven
Additional information
No response