Thanks for your message, Bernd,

Well that "specification" that you're talking about is just the previous
version of your schema. You could generate interfaces from your schema with
jOOQ (use the <interfaces/> flag) in a code generation run 1, then in code
generation run 2, re-generate the records, and try to compile them against
the previously generated interfaces. You can add interfaces to any
generated class using generator strategies, e.g.:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-matcherstrategy/

This does what you're asking for.

But I'm not really sure I understand the underlying use-case here. Is this
because you would like to hand-write your POJOs in a way to match the
generated code, but for some reason, *not* use the code generator for this?

On Wed, Aug 28, 2024 at 8:47 PM 'Bernd Huber' via jOOQ User Group <
jooq-user@googlegroups.com> wrote:

> I want to ask about the ".withRecords(true)" Functionality of the
> Jooq-Codegenerator...
>
> - is it possible to let those Pojos (which are generated as
> java14-records) adhere to some specification, that makes sure that whenever
> the db-table-schema changes i get a error in my IDE to see that i need to:
>   - add a field
>   - remove a field
>   - rename a field
>
> With specification a Java-Interface would be optimal.
>
> I guess the Java-Interface should work if it defines the default-getters
> of the java14-records.
>
> For example:
>
> public interface PersonSpec { String name(); int age(); }
>
> public record Person(String name, int age) implements PersonSpec {
>    // No additional methods needed; the record already provides them.
> }
>
>
> ---
>
> i currently think about using java14-Records instead of normal Pojos (with
> getters/setters) because the getters/setters can be harder to review in
> merge-requests. The getters/setters are often so much code that the
> review-person in the merge-request has much to review, while it would only
> be fields.
>
> But i don't want to loose the advantage of letting the Pojo implement and
> interface, which makes sure that if my db-table changes its schema i am
> forced to also fix the Pojo for that.
>
> --
> 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/c2fa6bd1-d999-452c-8a15-80a481680d90n%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/c2fa6bd1-d999-452c-8a15-80a481680d90n%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/CAB4ELO6R36K2YkjZLtQvZC6Qss1iU-1dVZx7vr8RAi7sY80HGw%40mail.gmail.com.

Reply via email to