Yeah, true. #6930 was there, too. Thanks for the pointer 2018-01-09 17:09 GMT+01:00 <[email protected]>:
> For anyone reading this thread: someone just pointed me to the > "<enumConverter>true</enumConverter>" flag in the configuration, and to > https://github.com/jOOQ/jOOQ/issues/6930. It seems that what I want is > jOOQ 3.11 :) > > > On Tuesday, January 9, 2018 at 4:39:13 PM UTC+1, [email protected] > wrote: >> >> Hi Lukas, >> >> Thanks for the quick response! >> >> The only issue I have with this approach is that I have to provide a >> separate (but trivial) binding or converter (e.g. deriving from >> EnumConverter) for each enum type, due to type erasure and the fact that >> the code generator always constructs the binding or converter using the >> default constructor. But I can see it would not be completely trivial to >> make such a constructor accept the two classes as parameters in a backward >> compatible and elegant way. I guess I'll just have to add those classes. >> >> Best regards, >> Sjoerd >> >> On Tuesday, January 9, 2018 at 4:01:44 PM UTC+1, Lukas Eder wrote: >>> >>> You can certainly do this by using a data type binding: >>> https://www.jooq.org/doc/latest/manual/code-generation/custo >>> m-data-type-bindings/ >>> >>> ... and optionally turning off code generation for enum types >>> >>> Note, you need a binding rather than a converter, as you will then have >>> to explicitly cast the bind value to your enum type in some situations. >>> >>> A simpler solution could be to implement a converter that simply maps >>> between jOOQ-generated enums and yours: >>> https://www.jooq.org/doc/latest/manual/code-generation/custom-data-types >>> >>> I wouldn't worry about efficiency here... >>> >>> Hope this helps, >>> Lukas >>> >>> 2018-01-09 15:35 GMT+01:00 <[email protected]>: >>> >>>> Hi all, >>>> >>>> Is there any way to have jOOQ map Postgres enum types to pre-existing >>>> Java enum types without using a jOOQ-generated enum type in between? >>>> >>>> What's currently generated for a Postgres enum type called "pgenum": >>>> >>>> *public final* TableField<SomeRecord, Pgenum> *VALUE* = >>>> createField("value", PostgresDataType.*VARCHAR*.asEnu >>>> mDataType(Pgenum.*class*), *this*, ""); >>>> >>>> If I want to map this to a Java enum type called "JavaEnum", I can use >>>> forcedType in the configuration and a converter, but then I end up with: >>>> >>>> *public final* TableField<SomeRecord, JavaEnum> *VALUE* = >>>> createField("value", PostgresDataType.*VARCHAR*.asEnu >>>> mDataType(Pgenum.*class*), *this*, "", *new* MyConverter()); >>>> >>>> What I want jOOQ to generate is something like (it seems the Postgres >>>> enum typename is the only thing that is used from Pgenum): >>>> >>>> *public final* TableField<SomeRecord, JavaEnum> *VALUE* = >>>> createField("value", PostgresDataType.*VARCHAR*.asEnumDataType( >>>> JavaEnum.*class*, "pgenum"), *this*, ""); >>>> >>>> Is there any way to do this? It seems rather inefficient to have to (a) >>>> write a converter from a generated enum to an enum with the same values, >>>> and (b) have to convert enum values every time at runtime while it could >>>> have converted straight from PG varchar to the JavaEnum. >>>> >>>> Kind regards, >>>> Sjoerd >>>> >>>> -- >>>> 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]. >>>> For more options, visit https://groups.google.com/d/optout. >>>> >>> >>> -- > 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]. > For more options, visit https://groups.google.com/d/optout. > -- 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]. For more options, visit https://groups.google.com/d/optout.
