ひがやすを技術ブログ

電通国際情報サービスのプログラマ

Boolean correspondence

現状のS2JDBCでは、boolean型を無条件にint型に変換していましたが、PostgreSQL等でエラーになってしまうため、元の仕様に戻します。そのかわり、CallableStatementのWrapperを提供することで、booleanをintに変更する処理を行わせたいと思います。
In current S2JDBC, the boolean type had been unconditionally converted into the int type. I think I return the specification to former specification, because it becomes an error by PostgreSQL etc. Instead, I 'd like to do processing to change boolean to int by offering Wrapper of CallableStatement.


BooleanToIntCallableStatment extends CallableStatementWrapper {
BooleanToIntCallableStatmentWrapper(CallableStatement original) {
super(original);
}
public void setBoolean(int index, boolean value) {
setInt(index, true ? 1 : 0);
}
}
後は、j2ee.diconにBooleanToIntCallableStatmentFactoryを組み込めば、S2JDBCでもS2Daoでもこの機能が有効になります。ResultSetFactoryと同じ仕組みですね。
If BooleanToIntCallableStatmentFactory is built into j2ee.dicon, this function becomes effective as for S2JDBC and S2Dao. It is the same mechanism as ResultSetFactory.