Thanks for your suggestion.

This  attempts to address the underlying issue at the wrong place: the
creation of specific types of predicates, when the feature you're really
looking for is a type safe representation of a key. With such a type safe
representation, *all* the key interactions will be type safe, not just the
creation of predicates. For example, your suggestion doesn't take into
account the multiple other kinds of predicates that may be interesting to
form, such as IN predicates, != predicates, NOT IN predicates, etc.

The good news is: we already have that feature! It's called embedded keys:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-embeddable-types/codegen-embedded-keys/

Once you turn that on, you will never be able to compare keys with scalar
values anymore. You'll always have to wrap the value(s) in an
EmbeddableRecord

I hope this helps,
Lukas

On Tue, Jul 2, 2024 at 9:33 AM Sven Haberer (Schroenser) <
schroen...@gmail.com> wrote:

> Feature idea
> Generate a method like
>
> public Condition getPrimaryKeyCondition(String strongly,  Integer typed,
> LocalDateTime parameters) {
>     return
> FOO.STRONGLY.eq(strongly).and(FOO.TYPED.eq(typed)).and(FOO.PARAMETERS.eq(parameters));
> }
>
> on each implementation of the Table interface.
>
> Benefits
> This method would allow to write type safe and compile time safe
> statements that deal with the primary key, for example:
>
> int numberOfDeletedRecords =
> dsl.delete(FOO).where(FOO.getPrimaryKeyCondition(strongly, typed,
> parameters)).execute();
>
> Also, it gets rid of the boilerplate code of creating the combined where
> condition, which might be hard to read but easy to mess up for a human
> developer.
>
> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/jooq-user/3496fa39-690a-4fd2-88ff-262b21d6ab9an%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/3496fa39-690a-4fd2-88ff-262b21d6ab9an%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 jooq-user+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jooq-user/CAB4ELO6i0chuYAVXsLvSHzoiE-3qgT%2BcWDnUPtdYkUm6T5z95g%40mail.gmail.com.

Reply via email to