ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject TypeHandlerCallback
Date Fri, 21 Apr 2006 23:16:13 GMT

<br><font size=2 face="sans-serif">I'm having some difficulty with a custom
TypeHandlerCallback. Working from the example in the user docs I implemented
the YesNoBoolTypeHandlerCallback. I declared it in my SqlMapConfig.xml
file as follows:</font>
<br>
<br><font size=2 color=blue>&lt;</font><font size=2 color=#800000>typeAlias</font><font
size=2 color=red>
alias</font><font size=2 color=blue>=&quot;</font><font size=2>Customer</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
type</font><font size=2 color=blue>=&quot;</font><font size=2>com.sybase.cosmos.domain.Customer</font><font
size=2 color=blue>&quot;&gt;&lt;/</font><font size=2 color=#800000>typeAlias</font><font
size=2 color=blue>&gt;</font>
<br><font size=2 color=blue>&lt;</font><font size=2 color=#800000>typeHandler</font><font
size=2 color=red>
javaType</font><font size=2 color=blue>=&quot;</font><font size=2>boolean</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
jdbcType</font><font size=2 color=blue>=&quot;</font><font size=2>VARCHAR</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
callback</font><font size=2 color=blue>=&quot;</font><font size=2>com.sybase.cosmos.dao.impl.ibatis.extentions.YesNoBoolTypeHandlerCallback</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br>
<br><font size=2 face="sans-serif">I then in the SqlMap that I want to
use it in I declare it as follows:</font>
<br><font size=2 color=blue>&lt;</font><font size=2 color=#800000>typeAlias</font><font
size=2 color=red>
alias</font><font size=2 color=blue>=&quot;</font><font size=2>YesNoTypeHandler</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
type</font><font size=2 color=blue>=&quot;</font><font size=2>com.sybase.cosmos.dao.impl.ibatis.extentions.YesNoBoolTypeHandlerCallback</font><font
size=2 color=blue>&quot;/&gt;</font>
<br><font size=2>&nbsp; </font><font size=2 color=blue>&lt;</font><font
size=2 color=#800000>resultMap</font><font size=2 color=red>
id</font><font size=2 color=blue>=&quot;</font><font size=2>CustomerResult</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
class</font><font size=2 color=blue>=&quot;</font><font size=2>Customer</font><font
size=2 color=blue>&quot;&gt;</font>
<br><font size=2>&nbsp; &nbsp; &nbsp;</font><font size=2
color=blue>&lt;</font><font size=2 color=#800000>result</font><font
size=2 color=red>
column</font><font size=2 color=blue>=&quot;</font><font size=2>customer_no</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>id</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br><font size=2>&nbsp; &nbsp; &nbsp;</font><font size=2
color=blue>&lt;</font><font size=2 color=#800000>result</font><font
size=2 color=red>
column</font><font size=2 color=blue>=&quot;</font><font size=2>activeind</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
property</font><font size=2 color=blue>=&quot;</font><font size=2>active</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
typeHandler</font><font size=2 color=blue>=&quot;</font><font size=2>YesNoTypeHandler</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br><font size=2 color=blue>....</font>
<br>
<br><font size=2 face="sans-serif">And I also defined a ParamterMap as
follows:</font>
<br><font size=2>&nbsp; </font><font size=2 color=blue>&lt;</font><font
size=2 color=#800000>parameterMap</font><font size=2 color=red>
id</font><font size=2 color=blue>=&quot;</font><font size=2>CustomerParam</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
class</font><font size=2 color=blue>=&quot;</font><font size=2>Customer</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>&gt;</font>
<br><font size=2>&nbsp; &nbsp; &nbsp; &nbsp; </font><font
size=2 color=blue>&lt;</font><font size=2 color=#800000>parameter</font><font
size=2 color=red>
&nbsp; property</font><font size=2 color=blue>=&quot;</font><font
size=2>active</font><font size=2 color=blue>&quot;</font><font
size=2 color=red>
&nbsp; typeHandler</font><font size=2 color=blue>=&quot;</font><font
size=2>YesNoTypeHandler</font><font size=2 color=blue>&quot;</font><font
size=2 color=red>
javaType</font><font size=2 color=blue>=&quot;</font><font size=2>boolean</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
jdbcType</font><font size=2 color=blue>=&quot;</font><font size=2>VARCHAR</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
nullValue</font><font size=2 color=blue>=&quot;</font><font size=2>N</font><font
size=2 color=blue>&quot;</font><font size=2 color=red>
</font><font size=2 color=blue>/&gt;</font>
<br><font size=2 color=blue>&lt;/</font><font size=2 color=#800000>parameterMap</font><font
size=2 color=blue>&gt;</font>
<br>
<br>
<br><font size=2 face="sans-serif">The problem that I am having is when
pasing a Customer object into the query I am getting an SQLException being
thrown stating:</font>
<br><font size=2 face="Courier New">Implicit conversion from datatype 'CHAR'
to 'BIT' is not allowed. &nbsp;Use the CONVERT function to run this query.</font>
<br>
<br>
<br><font size=2 face="sans-serif">It appears that the ParameterMap is
not using the YesNoTypeHandler when binding the parameters to the PreparedStatement.
&nbsp;So what am I missing?</font>
<br>
<br><font size=2 face="sans-serif">Thanks much...</font>
<br><font size=2 face="sans-serif"><br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font>

Mime
View raw message