Hi Adam,

Thanks a lot for sharing this. I'm positive this will be useful for quite a
few people on this list.

We're currently not investing too much in this area ourselves, as the
alternatives are much more compelling. E.g. using Kotlin or other
languages, or waiting until we finally have java.lang.Record. I have high
hopes for the impact of the latter on our ecosystem. The closest we can
offer is the <fluentSetters/> code generation configuration flag (which
works for mutable POJOs).

Of course, writing your own generator is a viable solution here as well. I
don't think there's anything wrong with this approach - I've recommended it
numerous times in the past.

Thanks,
Lukas

On Tue, Oct 22, 2019 at 8:46 AM Adam Zell <[email protected]> wrote:

> I have been playing around with immutable POJO support in
> *org.jooq.codegen.DefaultGenerator*.  This has been working well, but can
> be unwieldy when the POJO has more than 4-5 fields.  From
> https://www.jooq.org/doc/3.12/manual/code-generation/codegen-pojos/ :
>
> *immutablePojos: Immutable POJOs have final members and no setters. All
> members must be passed to the constructor*
>
> As Java lacks named parameters, calling the POJO constructor with many
> arguments can be confusing.  Therefore I thought that something like
> https://immutables.github.io/factory.html#pojo-constructors would be a
> nice fix.  The quickest implementation appeared to be overriding
> *JavaGenerator::generatePojoMultiConstructor* and inserting the necessary
> annotations.  My first attempt is at
> https://github.com/azell/jooq-utils/blob/master/generators/src/main/java/com/github/azell/jooq_utils/generators/BuilderGenerator.java
> .  Full POC can be found at https://github.com/azell/jooq-utils .
>
> I ended up copy and pasting almost all of the code from the
> *JavaGenerator* class.  The builder-specific logic is 6 lines of code.
> Is there a better way to do this?
>
> --
> 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/b10707e6-df9a-40a6-b0e1-b8317b05e563%40googlegroups.com
> <https://groups.google.com/d/msgid/jooq-user/b10707e6-df9a-40a6-b0e1-b8317b05e563%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/CAB4ELO5U%2BRF1VM644wAdvd9n10bYvUC6ZLvf5rtSyNTh6HKUMQ%40mail.gmail.com.

Reply via email to