-
Notifications
You must be signed in to change notification settings - Fork 41.2k
Improve support for jOOQ 3.15 by making R2dbcAutoConfiguration back off in the absence of a connection provider #26439
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
Comments
Thanks for raising this, @lukaseder. I agree that the majority of Spring Boot and jOOQ users won't care about R2DBC. With that in mind, have you considered making the R2DBC SPI an optional dependency of jOOQ? Users will have to add a dependency on a driver and possibly the connection pool as well anyway. Such a dependency will pull in the SPI transitively so making it optional won't require users of jOOQ and R2DBC to declare any additional dependencies and it'll save a little bit of weight for users of JDBC. If making the R2DBC API optional isn't possible for technical reasons, we could explore making the R2DBC auto-configuration back off in the absence of a If making the R2DBC API optional isn't possible for a more philosophical reason, we could leave the auto-configuration as-is and explore excluding it in our dependency management or in The options described above are what I've managed to think of thus far and I think they're in my order of preference. To summarise, they are:
|
Yes, but I haven't found a user-friendly and otherwise consistent way to add support for R2DBC SPI types in the jOOQ API. The main entry point is (as always):
I'm not sure if I understand this part. Is H2 here a placeholder for all the known providers? Or is H2's provider something that is always present?
That certainly seems to make sense. The SPI alone isn't doing anything. Of course, that would mean that if someone forgets to add the driver, they might not get the relevant error messages...?
No philosophical reasons, only technical ones. |
I don't think you're mistaken. If R2DBC is going to appear as a first-class citizen in the main jOOQ API it'll need to be on the classpath.
Sorry, that should have been
Yes, that's a downside and why this option wasn't first on my list. |
Another option would be to focus on the first two groups, i.e. those that want to work with either JDBC or R2DBC? As soon as either connection is configured, ignore the other? That would at least make the upgrade convenient for most of the jOOQ users. |
@lukaseder But what if I use H2 in-memory and don't configure a datasource because this is also auto-configured? |
@simasch I'm sorry, I didn't understand that |
That's already Boot's focus as we don't support auto-configuring both R2DBC and JDBC. If users want to use both R2DBC and JDBC, they have to configure JDBC themselves. We don't have any plans at the moment to change this. Boot auto-configuration has to run in a particular order and we decided when we added R2DBC support that it should go first. If R2DBC auto-configuration results in an To expand a bit on what we discussed above, at the moment, if you have the R2DBC SPI on the classpath and no R2DBC driver or connection URL, Boot will fail and advise you to either add the H2 driver or configure a connection URL. If we make the auto-configuration back off when there's no A refinement of requiring a |
Thanks a lot for the clarifications. That makes sense. |
We discussed the "harder to determine why that's happened" part of this comment today and thought that a |
That sounds great! I'm about to release jOOQ 3.15, this or next week. I'll ping you when it's ready |
So, here we go. jOOQ 3.15 including R2DBC support has been published: https://blog.jooq.org/2021/07/06/3-15-0-release-with-support-for-r2dbc-nested-row-array-and-multiset-types-5-new-sql-dialects-create-procedure-function-and-trigger-support-and-much-more/ |
For the record and for others finding this, I've documented the status quo also on Stack Overflow, as people will find their SpringBoot / jOOQ auto configuration to stop working after upgrading to 3.15.0: |
I've made a start on this and At the moment, |
@lukaseder When trying to build my Boot changes, I've just noticed that jOOQ 3.15.0 appears to require Java 11:
Is that intentional? |
Well, jOOQ's code generator works with JDBC, and only with JDBC... Not sure if that's relevant here?
How would it work for users who want both? Would they just include both starters?
Yes, the jOOQ Open Source Edition 3.15 requires Java 11. The commercial editions still support Java 8 |
That's unfortunate from a Spring Boot perspective. Our baseline is going to be Java 8 for all 2.x releases which means that we can't upgrade to jOOQ 3.15 till 3.0. It doesn't prevent us from doing this compatibility work, but the default version of jOOQ in Boot's dependency management will remain 3.14.x. |
I thought about this, but then I found the limitation arbitrary, both in jOOQ and in Spring Boot. For a while, the industry seemed to have come to a sort of agreement to keep baselines at a Java 8 level everywhere. Supporting less wasn't required (because yay, streams, lambas, default methods, But depending on how far away Spring Boot 3.0 is, this Java 11 (or 17) clock is ticking. With all the goodies that are available in Java 17 by now (records, sealed classes, pattern matching, etc. etc.), I would imagine even more libraries will start upgrading their baselines to something equally random as Java 8. Maybe, jOOQ is a first mover here - being dual licensed, and thus able to move forward faster. But I'm convinced other libraries will follow eventually. So, maybe there is another solution? An integrator like Spring Boot should be able to support multiple JDK versions out of the box, I think, especially considering how fast Java is moving now. I obviously don't know what it takes for this to work...
But then, you can't auto configure the R2DBC |
We already do so, supporting Java 8, 11, and 16 right now.
We may be able to do so via reflection. That's what we do for Jetty 10 which requires Java 11, while Jetty 9.x remains Boot's default version. |
OK, by "support" you mean you test things with these JDK versions, but you compile everything on a JDK 8 language level, right? Could there be 3 distributions of Spring Boot instead? And the Java 8 distribution would stick with jOOQ 3.14, whereas the other two would default to 3.15?
Ah yes, that makes sense. |
Right.
While technically possible (probably), we don't have any plans for anything like that. A single distribution served us well in 1.x where we supported Java 6, 7, and 8 and continues to do so in 2.x where we've supported, at various times, Java 8, 9, 10, 11, 12, 13, 14, 15, and 16. |
OK, makes sense. Well, as I said. So far, this worked well, because everyone agreed on the Java 8 baseline (or even less) for years. We'll see if that changes or not. Until then, upgrading jOOQ from Spring Boot's default of 3.14 isn't too hard. I had thought of another alternative which I'm going to keep in mind if this bothers too many people: jOOQ could publish a |
Until Spring Boot 2.6 ships with this fix, is there a chance of improving the error message in Spring Boot 2.5.x? I keep supporting folks with this problem (example here: https://twitter.com/amizrash/status/1448345414109962255) and linking to this Stack Overflow answer, which apparently isn't easy to find on google: I've added the error message No qualifying bean of type 'org.jooq.DSLContext' available: expected at least 1 bean which qualifies as autowire candidate. to the answer, maybe this helps with SEO for this problem. I think this problem leads to quite a bit of frustration among jOOQ users, and given how easy the fix is (once it is known, and it is very hard to know from the error message alone), I think a better error message would really help users. |
I've opened #28378 to see if we can improve the error message when there's no |
Thanks a lot, @wilkinsona |
For the record, I can confirm this issue disappears after upgrading to Spring Boot 2.6, great job everyone 💪 |
Would be great to get some small tutorial on how to configure reactive jooq with spring, I'm failing to boot spring-boot with 2.7.0-SNAPSHOT and jooq 3.15. Even though i have r2dbc in my classpath, connection string is The error is the one you guys added:
I tried searching jooq examples for reactive spring but I only found the blocking one (full deps)
|
To my understanding, because of the jOOQ 3.15 Open Source Edition's baseline of Java 11, Spring Boot 2.x cannot auto configure jOOQ 3.15 yet, only up to jOOQ 3.14, see #26439 (comment) As the error message states, you'll have to configure jOOQ yourself by wiring the R2DBC |
@lukaseder this was enough , flyway had other issues related to r2dbc but they aren't related to jooq (fixed them too) https://github.com/kamilgregorczyk/test-spring-reactive-jooq/blob/master/src/main/java/com/example/jpademo/TestSpringDataJpaApplication.java |
Yeah, that looks like it should work. If you're interested, that might be a good idea to document also on Stack Overflow, so others will find your solution more easily. You could ask and answer your own question, FAQ style: https://stackoverflow.blog/2011/07/01/its-ok-to-ask-and-answer-your-own-questions |
Starting with jOOQ 3.15 (hopefully due by the end of Q2 2021), jOOQ will support R2DBC: jOOQ/jOOQ#11700. For this, there is an
io.r2dbc:r2dbc-spi
dependency fromorg.jooq:jooq
in all distributions. Just like with JDBC, the R2DBC drivers, connection pools, etc. will be provided and configured by users.This now means that
R2dbcAutoConfiguration
will be activated and lead to false positive exceptions in 95% of all cases, because most people will still want to use theDataSourceAutoConfiguration
.A special case is when someone already excludes the
DataSourceAutoConfiguration
because they want to configure their ownDataSource
, or useDriverManager
:In that case, they will have to also exclude
R2dbcAutoConfiguration
when they upgrade to jOOQ 3.15.0:Not being a Spring Boot guru myself, I still wonder how we can prepare jOOQ + Spring Boot optimally to prevent any frustration from users when things break after the jOOQ 3.15 upgrade, keeping in mind:
DataSourceAutoConfiguration
and don't care about R2DBCDataSource
Ideas?
The text was updated successfully, but these errors were encountered: