I'm not sure if this is helpful but I've Incorporated lombok into our code
base at work that had similar functionality to immutable lib.  The focus is
removing boiler plate rather than making pojos immutable but might be
useful to your custom code generator.



Just a thought.



On Wed, Oct 23, 2019, 01:35 Lukas Eder <[email protected]> wrote:

> Thanks, see:
>
> - https://github.com/jOOQ/jOOQ/issues/6659
> - https://github.com/jOOQ/jOOQ/issues/9200
>
> On Wed, Oct 23, 2019 at 9:15 AM Adam Zell <[email protected]> wrote:
>
>> Thank you for the feedback.  One thing I noticed is that with Postgres
>> 11.5, jOOQ 3.12.2 is not detecting an identity column.  Given the following
>> SQL:
>>
>>
>> *CREATE TABLE public.jooq (id INTEGER GENERATED BY DEFAULT AS IDENTITY
>> NOT NULL, name VARCHAR(126) NOT NULL, CONSTRAINT JOOQ_PKEY PRIMARY KEY
>> (id));*
>>
>> testdb=# \d jooq;
>>                                     Table "public.jooq"
>>  Column |          Type          | Collation | Nullable |
>>  Default
>>
>> --------+------------------------+-----------+----------+----------------------------------
>> * id     | integer                |           | not null | generated by
>> default as identity*
>>  name   | character varying(126) |           | not null |
>> Indexes:
>>     "jooq_pkey" PRIMARY KEY, btree (id)
>>
>> But *column.getType(resolver()).isIdentity()* returns false.
>>
>> On Tuesday, October 22, 2019 at 12:58:35 AM UTC-7, Lukas Eder wrote:
>>>
>>> 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/eb006d84-3d00-4f11-9ff6-37221efeeede%40googlegroups.com
>> <https://groups.google.com/d/msgid/jooq-user/eb006d84-3d00-4f11-9ff6-37221efeeede%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/CAB4ELO6OS2rFMaFMno8KPtV9To_uJ2ud%2BaS%2BNrmp1TMcYUmUog%40mail.gmail.com
> <https://groups.google.com/d/msgid/jooq-user/CAB4ELO6OS2rFMaFMno8KPtV9To_uJ2ud%2BaS%2BNrmp1TMcYUmUog%40mail.gmail.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/CAJ7OkQ-KFJ_0niTCZLGkjokUoY1thvFMO9TyK%3DX%3D03YGZb7DRw%40mail.gmail.com.

Reply via email to