Hi Bernd, If you need to support mulitple versions of your API and this only involves the projection part of your query, then you must create a projection per DTO (preferably as Java Record). That could be abstracted in versioned repositories (DAOs).
There would also be a more generic approach to derive the projection directly from the constructor of the Java Record. But this would require reflection and is not compile-time checked. That’s how I would do it. Kind regards, Simon > On 13 Oct 2024, at 10:16, 'Bernd Huber' via jOOQ User Group > <[email protected]> wrote: > > Hello guys, > > i really loved the following video by Victor Rentea about REST API Design > Pitfalls. > - https://www.youtube.com/watch?v=CNlLWCvazcQ > > in my company we also need to build a Versioned REST-Api, which some specific > Clients can use in a secure way. > > Can someone recommend me an Article or Best-Practice how to integrate Jooq in > such a scenario ? > > I can think of something like ... > - i manually create versioned DTOs (ProductDTOV1, ProductDTOV2, ...) as > simple Pojos. > - i manually write Insert / Update / Delete Methods in my DAOs where i need > to boilerplate down all the fields i want to consider for each specific case. > - i write a Repository where i Select data and also concretely (boilerplate) > map each field i select into the versioned DTO. > - the Jooq-Codegen-Classes are only used in internal Jobs where REST is not > involved, as they are just an unnecessary middle-man for the REST use-cases. > > I know that Jooq does support everything i want to do with it, but I often > tend to overabstract, and i hope to find a simple way (even if its > boilerplate) to write REST-Apis with jooq, that do not involve overabstracted > solutions where they are counterproductive. > > I guess the outline i have shown here should work. > > best regards, > > Bernd Huber > > > -- > 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 [email protected] > <mailto:[email protected]>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jooq-user/ac30997e-16c1-4b74-adb7-03ebf8487255n%40googlegroups.com > > <https://groups.google.com/d/msgid/jooq-user/ac30997e-16c1-4b74-adb7-03ebf8487255n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/AB7CEF98-1E1A-410A-8A9D-EEFD36FC5ADF%40gmail.com.
