java - JOOQ forcedTypes to Boolean -
code generation worked fine. db char(1) field1,field2 mapped boolean in code base.
<forcedtypes> <forcedtype> <name>boolean</name> <expressions>field1,field2 </expressions> </forcedtype> </forcedtypes>
but while doing insert db,
a truncation error encountered trying shrink char 'false' length 1. error
the sql generated jooq insert mytable ("field1", "field2", ) values (cast(? boolean), cast(? boolean))
this trying insert false/true in db want insert 1 or 0. need help.
i have derby dev functional testing , oracle other environments. use same jooq generated stubs(generated using derby db) both db's. seems working fine oracle not derby.
http://blog.jooq.org/tag/boolean-data-type/ states oracle supports , derby not support conversion. need work around.
using data type rewriting in code generator
you're making use of feature "data type rewriting" in code generator configuration. means jooq's runtime has no idea actual data type in database. behaves though data type is boolean
. means:
- the oracle jdbc driver convert java
boolean
bind values1
or0
number
columns, or'1'
or'0'
string columns. - the derby jdbc driver won't convert type instead expect real
boolean
column in database.
if want proceed way, have make derby column type actual boolean
, not char(1)
.
specifying converter
in code generator
another option use jooq converter
instead, translate java boolean
java string
first, before passing value database. way, can use same data type in both of databases. this documented here, in manual.
Comments
Post a Comment