On Tue, Oct 2, 2018 at 7:35 AM Ganesh <[email protected]> wrote:
> Thanks for replying... I am not using JOOQ code generator.
>
Why not? :-) It would help you so much with your SQL, specifically when
these vendor specific data types are involved. But of course, you can do
the code generator's work manually. I'll explain below.
> However, I am able to insert rows in the DB using SQL workbench which
> happily accepts String values for enum columns..
>
That's because you're not using a bind variable in SQL workbench, but a
literal. And PostgreSQL can convert between string literals and user
defined types more easily than if you're using bind variables. You could,
of course, tell jOOQ to use a literal as well, e.g. by using
DSL.inline(request.getStatus()). Or, you use the code generator. Or, you
explicitly specify types on your table columns. In your case:
...set(field(name("status"),
SQLDataType.VARCHAR.asEnumDataType(StatusEnum.class)), request.getStatus())
Your StatusEnum will need to implement org.jooq.EnumType for this to work
correctly.
Or really. You could just use the code generator :)
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 [email protected].
For more options, visit https://groups.google.com/d/optout.