Hi James 2017-02-17 1:36 GMT+01:00 <[email protected]>:
> Hi Lukas; > > Thanks for all your awesome work on jOOQ! > > I'm having troubles finding any working example of how to create a > converter or a custom binding from a postgres enum to the jooq generated > enum (or some means to use only the enum we have defined elsewhere). > The Postgres generated enum doesn't need any custom binding, it is bound correctly by the built-in DefaultBinding There's an example for how to use the built-in EnumConverter class at the bottom of this page of the manual: https://www.jooq.org/doc/latest/manual/sql-execution/fetching/data-type-conversion > Because we share code with clients, we can't use the generated enum, and > so far, the only way to get jOOQ to play nice is to change all of our > postgres ENUM types to raw text to get support for a Converter<String, > MyEnum>. > > What does it take to get conversion from <MyEnum, JooqsMyEnum> ? > > I'm not opposed to writing my own Binding, however, this looks > non-trivial, and would rather here from the source than muddle something > together that might work for my test cases, but fail around some > unconsidered edge case. > You can simply write a Converter<JooqsMyEnum, MyEnum> (where <T, U> means <T = Database type, U = Your type>) and set the code generator to apply that using forcedType configuration: https://www.jooq.org/doc/latest/manual/code-generation/custom-data-types You could do it with a Binding instead of a Converter, too, but that would be a bit more complicated. Let me know if you have any specific questions or if something isn't working for you, and I'll be more than happy to help. Lukas -- 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.
