-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infer database capabilities without opening a JDBC connection on runtime init #13522
Comments
CC @gsmet: this issue is related to the discussion we had regarding the introduction of a property to set the database version. I think this will have to be a build-time property, unfortunately... |
Right, great to see we had an issue already. So "capabilities" are better represented in ORM 6 with the version; having that exposed would be really nice and a more user friendly way to expose this. |
Note the database capabilities we're talking about go way beyond just the vendor and DB version. For example, Allowing it to determine the max length of the I'm sure there are plenty of such tricks in Hibernate ORM, so addressing them smartly at build time will require a good deal of thinking. |
Another potential issue somewhat related to this feature is that Hibernate ORM stores the "JDBC metadata" globally, which can be a problem in a multi-tenant scenario with multiple databases. From what I can see the metadata is retrieved from the database corresponding to the default tenant and then used globally for all tenants: I can see this being a problem if different tenants have different database version/configuration with different metadata. Solving this (separate) issue would probably require substantial changes in Hibernate ORM. Basically we'd need some dialect-related metadata to be tenant-scoped ( Anyway, I'm going on a tangent here, but it's good to keep this in mind. |
FWIW we'll need to address at least this upstream issue before we can work on this, and maybe more: https://hibernate.atlassian.net/browse/HHH-17425 |
All relevant problems seem to have been solved upstream: We should be able to integrate the feature in Quarkus, which will involve:
|
BTW https://hibernate.atlassian.net/browse/HHH-18601 could help make this "offline startup" feature safer, but is not an absulte requirement: this can come as an improvement later. |
Description
cc @Sanne , as discussed. Creating to keep track of this potential enhancement.
#13435 made sure that we correctly infer database capabilities when the application boots, by opening a connection to the database and requesting database metadata from the JDBC driver.
This connection is problematic if the database is not available when the application boots. In that case, the connection will fail, the exception will be logged and Hibernate ORM will assume that none of the "extra" capabilities are available. Which may lead to runtime errors, such as #12412.
Ideally, we should provide hardcoded capabilities for well-known databases and drivers, so that the JDBC connection is not always needed.
Implementation ideas
We could pass the required metadata along with the driver/dialect metadata, during static init. At runtime, if we have such metadata (i.e. we're dealing with a well-known database), we override the
JdbcEnvironementInitiator
to take the metadata into account; otherwise, we fall back to the default initiator which will open a JDBC connection.The text was updated successfully, but these errors were encountered: