How to use DSL.val with custom enum type

11 views
Skip to first unread message

Petar Andreev

unread,
May 6, 2024, 8:29:19 AMMay 6
to jOOQ User Group
Hi, I have upgraded to jooq 3.19.8 and I have an enum, e.g.
forcedType {
userType = 'com.example.IndexType'
enumConverter = true
includeExpression = '(?i:search\\.example\\.type)'
}

Then I want to use this enum with DSL.val() in

db.select(
EXAMPLE.ID,
DSL.val(IndexType.SOMETHING))
.from(EXAMPLE)
....
but the latest jooq gives me an exception:
It is strongly recommended not looking up DataType<T> references from Class<T> references by
relying on the internal static type registry. For example, avoid calling DSL.val(Object) or
DSL.val(Object, Class), and call DSL.val(Object, DataType), providing an explicit DataType
reference to jOOQ if your DataType uses a Converter or a Binding. If you think jOOQ should
be able to infer your user type in your particular query, please report a bug here:
https://jooq.org/bug

Please help me how shall I use DSL.val with such enums as I don;t know what DataType I should use. Thanks

Lukas Eder

unread,
May 6, 2024, 8:32:22 AMMay 6
to jooq...@googlegroups.com
Hi Petar,

A DataType<IndexType> instance is available from your SEARCH.EXAMPLE.TYPE column, for example. It might be available elsewhere, too. You can create it as well manually in various ways, e.g. SQLDataType.VARCHAR.asConvertedDataType(...).

I hope this helps,
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 jooq-user+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jooq-user/dd0cb81b-f42b-4e37-ad26-0d68a41c5b1dn%40googlegroups.com.

Petar Andreev

unread,
May 7, 2024, 1:16:47 AMMay 7
to jOOQ User Group
Thanks Lukas, it works

Lukas Eder

unread,
May 7, 2024, 2:11:43 AMMay 7
to jooq...@googlegroups.com
Thanks for your feedback.
I've created an issue to improve the warning message to include these hints:

Reply all
Reply to author
Forward
0 new messages