Hello Witold, Yes, I can reproduce this. Thanks for reporting. This reminds me why I haven't documented this feature yet: It is still in a somewhat experimental state since it was implemented. As a reminder, I have registered #2152 for this: https://github.com/jOOQ/jOOQ/issues/2152
On the other hand, this shows that maybe re-writing SQL data types (without converters) doesn't work reliably at all. jOOQ needs some sort of type information, when binding variables through the JDBC API. If BOOLEAN is the only information available to jOOQ, it cannot guess that TINYINT (or NUMBER) would be a more suitable type. In other words, this information is lost during the code generation process. So maybe, converters are the only correct way to handle booleans here...? I'll have to further investigate this issue. The correct handling of SQL NULL through 14 dialects and 14 JDBC drivers is quite a pain ;-) Cheers Lukas 2013/1/31 Witold Szczerba <[email protected]>: > Hi, > I have just checked the solution with no custom converter, used the built-in > BOOLEAN. > It does not work well with Oracle (don't know about other databases). The > problem is with null values: > > org.jooq.exception.DataAccessException: SQL [null]; Invalid column type: 16 > at org.jooq.impl.Util.translate(Util.java:649) > at > org.jooq.impl.AbstractBindContext.bindValue(AbstractBindContext.java:142) > at org.jooq.impl.Val.bind(Val.java:544) > at > org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:154) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:111) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:71) > at org.jooq.impl.FieldMapForInsert.bind(FieldMapForInsert.java:135) > at > org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:154) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:111) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:71) > at org.jooq.impl.FieldMapsForInsert.bind(FieldMapsForInsert.java:135) > at > org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:154) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:111) > at org.jooq.impl.InsertQueryImpl.bindInsert(InsertQueryImpl.java:360) > at org.jooq.impl.InsertQueryImpl.bind(InsertQueryImpl.java:330) > at > org.jooq.impl.AbstractBindContext.bindInternal(AbstractBindContext.java:154) > at org.jooq.impl.AbstractBindContext.bind(AbstractBindContext.java:111) > at org.jooq.impl.Factory.bind(Factory.java:736) > at org.jooq.impl.AbstractQuery.execute(AbstractQuery.java:254) > at org.jooq.impl.TableRecordImpl.storeInsert(TableRecordImpl.java:189) > at org.jooq.impl.TableRecordImpl.storeUsing(TableRecordImpl.java:150) > at org.jooq.impl.UpdatableRecordImpl.store(UpdatableRecordImpl.java:78) > > The offending code: > > AbstractBindContext: > @Override > public final BindContext bindValue(Object value, Class<?> type) { > try { > return bindValue0(value, type); > } > catch (SQLException e) { > throw Util.translate(null, e); > } > } > > where, > value is null > type is java.lang.Boolean > > When switched back to my converter, the null value of Boolean (SQL > Types.BOOLEAN (16) gets replaced by null value of TINYINT (-6) and Oracle > JDBC driver handles it correctly. > I am using driver: ojdbc6.jar > Implementation-Vendor: Oracle Corporation > Implementation-Title: JDBC > Implementation-Version: 11.2.0.2.0 > > Regards, > Witold Szczerba > > > On 30 January 2013 13:29, Lukas Eder <[email protected]> wrote: >> >> This issue was recently encountered on Stack Overflow: >> http://stackoverflow.com/q/14123209/521799 >> >> You can force a set of fields matched by a regex (not a data type, such as >> NUMBER(1, 0)) to the SQL BOOLEAN data type. This will then work for both H2 >> and Oracle >> >> Cheers >> Lukas >> >> 2013/1/28 Witold Szczerba <[email protected]> >>> >>> Hi, >>> I am using code generator and without applying my converter the generated >>> code looks like this: >>> (class names simplified) >>> >>> public class Estate extends UpdatableTableImpl<EstateRecord> { >>> [...] >>> public final TableField<EstateRecord, Byte> DEVELOPED = >>> createField("DEVELOPED", SQLDataType.TINYINT, this); >>> >>> //with converter applied: >>> >>> public final TableField<EstateRecord, Boolean> DEVELOPED = >>> createField("DEVELOPED", SQLDataType.TINYINT.asConvertedDataType(new >>> OracleBooleanConverter()), this); >>> [...] >>> } >>> >>> I do believe it could handle boolean type conversion on the fly (in >>> Oracle the column type is NUMBER(1,0), but my case is about code generator. >>> >>> Regards, >>> Witold Szczerba >>> >>> >>> On 28 January 2013 13:13, Ben Hood <[email protected]> wrote: >>>> >>>> Hey Witold, >>>> >>>> JOOQ _should_ handle this seamlessly - our app runs on H2 and Oracle >>>> without the need to do any custom conversion. AFAIK, the JOOQ factory reads >>>> the dialect at runtime and issues the appropriate SQL transparently, as >>>> long >>>> as your boolean encoding is vaguely sane (e.g. something like 1,0, true, >>>> false). Have you been seeing issues with this? >>>> >>>> Cheers, >>>> >>>> Ben >>>> >>>> On Sunday, 27 January 2013 at 17:27, Witold Szczerba wrote: >>>> >>>> Hi, >>>> I am migrating from H2 to Oracle (H2 was used in early dev to kick start >>>> the project, customer forces us to use Oracle). There are few problems, one >>>> of which is the Oracle does not support boolean types, so following manual >>>> section: >>>> >>>> Custom data types and type conversion >>>> http://www.jooq.org/doc/2.6/manual/code-generation/custom-data-types/ >>>> >>>> Snippets available: https://gist.github.com/4649307 >>>> >>>> My question is: is it possible to enable that converter only when >>>> operating on Oracle and ignore it otherwise? >>>> >>>> Regards, >>>> Witold Szczerba >>>> >>>> -- >>>> >>>> >>>> >>>> >>>> -- >>>> >>>> >>> >>> >>> -- >>> >>> >> >> >> -- >> 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/groups/opt_out. >> >> > > > -- > 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/groups/opt_out. > > -- 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/groups/opt_out.
