[ http://issues.apache.org/jira/browse/IBATIS-106?page=comments#action_62811 ] Alexandru Barbat commented on IBATIS-106: -----------------------------------------
My opinion is that you have to implement an special handler. and in resultMap you have to specify it something like this: ... <typeAlias alias="booleanHandler" type="org.fmk.ibatis.handler.BooleanTypeHandlerCallback"/> ... <resultMap id="example-map-result" class="java.util.HashMap"> <result property="action" column="ACTION"/> <result property="mode" column="MODE_ACCESS" typeHandler="booleanHandler"/> </resultMap> Example (Special handler): import java.sql.SQLException; ... import com.ibatis.sqlmap.client.extensions.ParameterSetter; import com.ibatis.sqlmap.client.extensions.ResultGetter; import com.ibatis.sqlmap.client.extensions.TypeHandlerCallback; public class BooleanTypeHandlerCallback implements TypeHandlerCallback { private static int refDbTrue = Integer.parseInt(IConstantes.TRUE_INT); public Object getResult(ResultGetter getter) throws SQLException { int i = getter.getInt(); if (i == refDbTrue) { return new Boolean(true); } else { return new Boolean(false); } } public void setParameter(ParameterSetter setter, Object parameter) throws SQLException { boolean b = ( (Boolean) parameter).booleanValue(); if (b) { setter.setInt(1); } else { setter.setInt(0); } } public Object valueOf(String s) { if ( (IConstantes.TRUE_INT).equalsIgnoreCase(s)) { return new Boolean(true); } else { return new Boolean(false); } } } > Retrieving bit value from data base > ----------------------------------- > > Key: IBATIS-106 > URL: http://issues.apache.org/jira/browse/IBATIS-106 > Project: iBatis for Java > Type: Task > Components: SQL Maps > Environment: SQL server > Reporter: yogneder > > I’m having a problem while retrieving the data from a column of the table > whose data type is ‘bit’. The values stored are 0 or 1. However when I try > retrieve the values it returns true or false based on the value. > How can I retrieve the values in the form of 1 or 0. > Pls help. This is urgent… > Thanks in Advance. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - If you want more information on JIRA, or have a bug to report see: http://www.atlassian.com/software/jira