Hello Sergey,

> We use char 'Y'/'N' for encoding boolean values.
> Probably we have to define custom type handler that converts values from
> boolean to string and vice versa (both resultset and procedure paramaters).

Reading these characters as boolean is already possible. You can
convert them using various methods, for instance

List<Boolean> list = result.getValues(field, Boolean.class);
Boolean value = record.getValue(field, Boolean.class);

I realise just now, that this is not publicly documented, though!

Besides, there is
http://www.jooq.org/javadoc/latest/org/jooq/Field.html#isTrue%28%29
http://www.jooq.org/javadoc/latest/org/jooq/Field.html#isFalse%28%29

But writing 'Y' / 'N' from a Java boolean is a bit more difficult. I
agree that adding Y/N, YES/NO, ON/OFF boolean types might be useful.
I'll add it to the feature roadmap:
https://sourceforge.net/apps/trac/jooq/ticket/968

> Here is example how this problem can be resolverd in mybatis:
> http://jroller.com/RickHigh/entry/ibatis_how_do_you_map

I'll consider that, thanks.

> Is it possible to map simple char - encoded enumerations (for example 'E -
> Enabled, 'D' - Disabled, 'S' - Suspended) type to java enum (without master
> table)?

Currently, enum types are only supported where they exist natively,
i.e. in MySQL and Postgres. I had previously thought about reading
check constraints for enum types, although that is a bit tricky as
they are usually not formally available in a non-source-code form.
Parsing a check constraint's source code might not be trivial. But
when custom type mapping is available, custom enum types could easily
be mapped, too. Maybe, they would need to implement org.jooq.EnumType:
http://www.jooq.org/javadoc/latest/org/jooq/EnumType.html

Of course, this would resolve the 'Y' / 'N' boolean feature, too.

I'll give this a thought for jOOQ 2.0.1. API and Implementation ideas
are welcome, of course!

Cheers
Lukas

Reply via email to