ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher.Mathru...@sybase.com
Subject Re: TypeHandlerCallback
Date Sat, 22 Apr 2006 05:12:24 GMT

<br><font size=2 face="sans-serif">Ok, I've been reading the docs in more
detail and looking at examples posted by many. So I removed the typeAlias,
the typeHandler from the resultMap, and the parameterMap as well. I then
changed my typeHandler mapping to be the following:</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><b>CHAR</b></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><font size=3> <br>
</font>
<br><font size=3>Unfortunately this still did not resolve my problem. So
I read more and more with no solution in sight. Finally I saw from many
of the examples that no one was specifying the jdbcType attribute. I thought
that this would be needed to correctly map the jdbcType to the javaType,
but what the heck! It's late, it's Friday, and I've wasted a large amount
of time on this problem. So I removed the jdbcType from the declaration
and ... Bravo!!! It worked!</font>
<br>
<br><font size=3>I guess I simply needed a larger hammer to hit me on the
head.</font>
<br>
<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>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Christopher.Mathrusse@sybase.com</b>
</font>
<p><font size=1 face="sans-serif">04/21/2006 04:16 PM</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Please respond to<br>
user-java@ibatis.apache.org</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">To</font></div>
<td valign=top><font size=1 face="sans-serif">user-java@ibatis.apache.org</font>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">cc</font></div>
<td valign=top>
<tr>
<td>
<div align=right><font size=1 face="sans-serif">Subject</font></div>
<td valign=top><font size=1 face="sans-serif">TypeHandlerCallback</font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><font size=2 face="sans-serif"><br>
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><font size=3>
<br>
</font><font size=2 color=blue><br>
&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><font size=3>
</font><font size=2 color=blue><br>
&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><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
I then in the SqlMap that I want to use it in I declare it as follows:</font><font
size=3>
</font><font size=2 color=blue><br>
&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><font size=3>
</font><font size=2><br>
 &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><font size=3>
</font><font size=2><br>
 &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><font size=3> </font><font
size=2><br>
 &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><font size=3> </font><font
size=2 color=blue><br>
....</font><font size=3> <br>
</font><font size=2 face="sans-serif"><br>
And I also defined a ParamterMap as follows:</font><font size=3> </font><font
size=2><br>
 &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><font size=3> </font><font
size=2><br>
 &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><font size=3> </font><font
size=2 color=blue><br>
&lt;/</font><font size=2 color=#800000>parameterMap</font><font size=2
color=blue>&gt;</font><font size=3>
<br>
<br>
</font><font size=2 face="sans-serif"><br>
The problem that I am having is when pasing a Customer object into the
query I am getting an SQLException being thrown stating:</font><font size=3>
</font><font size=2 face="Courier New"><br>
Implicit conversion from datatype 'CHAR' to 'BIT' is not allowed. &nbsp;Use
the CONVERT function to run this query.</font><font size=3> <br>
<br>
</font><font size=2 face="sans-serif"><br>
It appears that the ParameterMap is not using the YesNoTypeHandler when
binding the parameters to the PreparedStatement. &nbsp;So what am I missing?</font><font
size=3>
<br>
</font><font size=2 face="sans-serif"><br>
Thanks much...</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
Chris Mathrusse<br>
christopher.mathrusse@sybase.com<br>
Sybase, Inc<br>
One Sybase Drive<br>
Dublin, CA 94568<br>
(925) 236-5553</font><font size=3> </font>
<br>

Mime
View raw message