Oh, I see, thanks for sharing. Here's what I can tell what the problems are:
1. You're trying to bind String to the <T> type of the converter. That's not correct. If you want to use a Converter, then it will have to be converting from the generated Mood Enum type to your own custom Mood Enum type. As it stands now, for some reason, the generated enum type is absent in your configuration, probably because you excluded it. You'll have to re-enable that generation. 2. If you really don't want any jOOQ-generated enums, then you will need to use a data type binding ( http://www.jooq.org/doc/latest/manual/sql-building/queryparts/custom-bindings/) rather than a converter. jOOQ won't know how to bind the JDBC type correctly to JDBC (including casts, etc.). You'll have to do that manually. But then again, why not use jOOQ's built-in enum support... 3. Your <U> type is Mood[], not Mood. You need to implement a converter that can handle enum arrays, not individual enum values. I hope this helps already. Let me know if you encounter any further issues. Lukas 2016-06-20 13:18 GMT+02:00 Emrul Islam <[email protected]>: > Hi Lukas, > > An existing enum is generated and it works fine. However, I want to map > to an Enum defined in an external package. > > > Thanks > > On Sunday, June 19, 2016 at 7:04:52 PM UTC+1, Lukas Eder wrote: >> >> Hmm, the interesting thing here is to see why the MOOD enum type is not >> generated. Did you perhaps exclude it from the code generation? Or is it in >> a different schema? jOOQ supports PostgreSQL enum types and enum type >> arrays out of the box, which is why I'm asking... >> >> Lukas >> >> 2016-06-18 2:29 GMT+01:00 Emrul Islam <[email protected]>: >> >>> Oops, cut & paste error - my MoodConverter is so: >>> >>> public class MoodConverter extends EnumConverter<String, Mood> { >>> public MoodConverter() { >>> super(String.class, Mood.class); >>> } >>> } >>> >>> >>> On Saturday, June 18, 2016 at 2:25:44 AM UTC+1, Emrul Islam wrote: >>>> >>>> Hi, >>>> >>>> I am using Postgres and have the following schema: >>>> >>>> CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy'); >>>> >>>> CREATE TABLE test_enum_array >>>> ( >>>> "eArray" mood[] >>>> ) >>>> >>>> In my Jooq codegen config I have the following: >>>> >>>> <customTypes> >>>> <customType> >>>> <name>Mood</name> >>>> <type>org.test.enums.Mood</type> >>>> <converter>org.test.db.util.MoodConverter</converter> >>>> </customType> >>>> </customTypes> >>>> <forcedTypes> >>>> <forcedType> >>>> <name>Mood</name> >>>> <expression>eArray</expression> >>>> </forcedType> >>>> </forcedTypes> >>>> >>>> >>>> The generated code looks like this: >>>> >>>> public final >>>> TableField<org.test.db.jooq.shared.tables.records.test_enum_array, Mood[]> >>>> eArray = createField("eArray", >>>> org.jooq.impl.DefaultDataType.getDefaultDataType("org.test.enums.Mood").getArrayDataType(), >>>> this, "", new MoodConverter()); >>>> >>>> >>>> My MoodConverter is like so: >>>> >>>> public class MoodConverter extends EnumConverter<String, Mood> { >>>> public BaseTypeIdConverter() { >>>> super(String.class, Mood.class); >>>> } >>>> } >>>> >>>> >>>> But IntelliJ throws up a 'Cannot resolve method' IDE warning. >>>> >>>> I can see that MoodConverter requires a string but appears to be >>>> getting passed the entire array so that's clearly wrong. However, I'm not >>>> clear on how to configure Jooq to give me the result I want. >>>> >>>> Thanks! >>>> >>> -- >>> 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.
