Hello everyone,
I hope this message finds you well. I’d like to share an idea for a potential feature request, inspired by a brief discussion on SO with Lukas.
INTRO When starting a Java Spring project, developers often use JPA for data mapping because it allows for quick and straightforward setup. However, as the project grows, they start encountering performance issues like the infamous N+1 problem et similia.
At this stage, devs make one of the two things happen:
Unfortunately, most of the times ,both approaches result in code that is hard to read, inconsistent, and difficult to maintain. At least in my experience.
THE IDEA Here’s the idea: a strongly opinionated way of defining queries that starts from the basic thought steps when dealing with data querying in Java. The focus would be on defining a query plan with filter criteria and specifying what to load and how it should be loaded, possibly even in a recursive fashion.
At a glance it could look something like this: https://github.com/thestroke82/leanquery/blob/master/src/main/java/org/frappa/leanquery/controller/CustomerController.java I've worked with a custom solution very much like this in the past and observed it performing its job remarkably well. The strongest advantage of such an approach is that as the codebase grows, readability remains practically constant, significantly improving maintainability. CONCLUSION The ideas are now out in the open, both in words and code (see the GitHub link above). I’m eager to hear your thoughts and advice, and I hope we can work together to evolve this concept into a formal feature request for JOOQ.
One final request: Please refrain from comments that patronize or dismiss the idea with statements like "JPA already does that" or "X does that too." Instead, I’m looking for constructive feedback and suggestions on how we can make this feature a valuable addition to the JOOQ ecosystem.
Thank you for your time and consideration. I look forward to your feedback and collaboration!
--
You received this message because you are subscribed to the Google Groups "jOOQ User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/99bbd0c3-e5af-4ee7-a897-7ff869098288n%40googlegroups.com.
Thank you for your thoughtful response, Lukas. I'd like to clarify a few points:
I don't consider my idea revolutionary, nor do I aim to build the next big framework from it. It was a simple attempt to solve a small problem.
While my idea resembles GraphQL to some extent, GraphQL is far more ambitious and comes with an "all or nothing" constraint. Additionally, I'm not a fan of the "querying by JSON example" approach, but that's just a personal preference. All I wanted is something that makes sense inside the domain: there are books and there are rentals, what do you want to load? And how?
I wasn't aware of Oracle 23c AI, so I'll look into it as soon as possible.
I did not intend to undermine or criticize jOOQ. I use it in every project, all the time. As you mentioned, jOOQ is designed to mitigate the impedance mismatch problem at large, not the simple traversal/filter issue I proposed. It only makes sense that you decided not to include this discussion as a new feature in jOOQ.
My critique of MULTISET was poorly phrased. MULTISET is a fantastic feature in jOOQ, possibly one of the best. However, it’s not a "pattern" in and of itself. Like any flexible tool, it can get very ugly very quickly if used by inexperienced developers. My idea was meant to act as a "cage" to enforce a strongly defined approach for developers.
In my opinion, and I don't want to play the Martin Fowler here, the impedance mismatch has won, database side. Almost every OOP framework/architecture that accesses databases is generally designed around inserts, updates, and selects. For instance, the classic layered architecture is driven by the DAO/repository layer, which often results in a procedural approach rather than an OOP one. Phrases like "composition is favored over inheritance" seem to have been coined only to somehow relieve us from the burden of this heart-felt truth. One of the reasons for the recent success of Hexagonal/Onion architectures, to name another example, is that they strive to bring us back to the fundamentals of OOP, don't they?
Ultimately, as you suggested, the best approach might be to build an opinionated API on top of jOOQ, similar to what I tried to achieve in my demo application.
Thanks again, and I apologize if I came across as aggressive or critical.
There has also been an idea in the past to allow for other relational operators on arbitrary table expressions, such as Table.select() but it was rejected because the time wasn't ripe for such an operator yet, at the time: