Return-Path: Delivered-To: apmail-ibatis-user-cs-archive@www.apache.org Received: (qmail 17554 invoked from network); 18 Jul 2007 15:18:13 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 18 Jul 2007 15:18:13 -0000 Received: (qmail 28780 invoked by uid 500); 18 Jul 2007 15:18:01 -0000 Delivered-To: apmail-ibatis-user-cs-archive@ibatis.apache.org Received: (qmail 28762 invoked by uid 500); 18 Jul 2007 15:18:01 -0000 Mailing-List: contact user-cs-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-cs@ibatis.apache.org Delivered-To: mailing list user-cs@ibatis.apache.org Received: (qmail 28749 invoked by uid 99); 18 Jul 2007 15:18:01 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jul 2007 08:18:01 -0700 X-ASF-Spam-Status: No, hits=3.4 required=10.0 tests=HTML_MESSAGE,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (herse.apache.org: 74.208.4.195 is neither permitted nor denied by domain of SRS0=dTsc=MQ=selkefamily.com=tony@srs.perfora.net) Received: from [74.208.4.195] (HELO mout.perfora.net) (74.208.4.195) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 Jul 2007 08:17:56 -0700 Received: from [172.23.126.14] (helo=ntxsmtpus.exchange.xchg) by mrelay.perfora.net (node=mrus1) with ESMTP (Nemesis), id 0MKpCa-1IBBHT3W3r-0006X5; Wed, 18 Jul 2007 11:17:36 -0400 Received: from ntxbeus15.exchange.xchg ([172.23.130.4]) by ntxsmtpus.exchange.xchg with Microsoft SMTPSVC(6.0.3790.3959); Wed, 18 Jul 2007 11:17:29 -0400 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C7C94E.A3F7580C" Subject: ITypeHandlerCallback supported in ? Date: Wed, 18 Jul 2007 11:16:35 -0400 Message-ID: <937165F5D8D6594DB0203505D392EC6567C95B@ntxbeus15.exchange.xchg> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: ITypeHandlerCallback supported in ? Thread-Index: AcfIt5jzDCBPq7jhRw2Ouak96zgN1gAlpUVQ From: "Tony Selke" To: X-OriginalArrivalTime: 18 Jul 2007 15:17:29.0105 (UTC) FILETIME=[C14D5010:01C7C94E] X-Provags-ID: V01U2FsdGVkX1/n5S9pmouysKcibuhCLFAf6kqu8nyUMQSvFcP 5a0j8A9gPJ52NdyHhPh14iw6z/VvrwsJONFZM0vjJCKnkzizA X-Virus-Checked: Checked by ClamAV on apache.org This is a multi-part message in MIME format. ------_=_NextPart_001_01C7C94E.A3F7580C Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I am trying to implement a custom type handler in my project. I have followed the documentation and the existing example in the NUnit tests. =20 Here is my type converter class: =20 <><><><><><>=20 =20 public class CharBoolHandlerCallback : ITypeHandlerCallback { private const string DB_TRUE_VAL =3D @"Y"; private const string DB_FALSE_VAL =3D @"N"; =20 public object ValueOf(string nullValue) { if (DB_TRUE_VAL.Equals(nullValue, StringComparison.OrdinalIgnoreCase))=20 return true; else if (DB_FALSE_VAL.Equals(nullValue, StringComparison.OrdinalIgnoreCase))=20 return false; else throw new DataMapperException(); } =20 public object GetResult(IResultGetter getter) { if (getter.Value =3D=3D null || getter.Value =3D=3D = DBNull.Value)=20 throw new DataMapperException(); =20 string dbVal =3D Convert.ToString(getter.Value); =20 if (DB_TRUE_VAL.Equals(dbVal, StringComparison.OrdinalIgnoreCase))=20 return true; else if (DB_FALSE_VAL.Equals(dbVal, StringComparison.OrdinalIgnoreCase))=20 return false; else throw new DataMapperException(); } =20 public void SetParameter(IParameterSetter setter, object parameter) { setter.Value =3D Convert.ToBoolean(parameter) ? DB_TRUE_VAL : DB_FALSE_VAL; } =20 public object NullValue { get { throw new InvalidCastException(); } } } =20 <><><><><><>=20 =20 I have the following in my main sqlmap.config: =20 <><><><><><>=20 =20 =20 =20 <><><><><><>=20 =20 And my result map looks like: =20 <><><><><><>=20 =20 =20 <><><><><><>=20 =20 All of my iBATIS configuration loads. However, when I try to get an object instance, iBATIS throws a SqlDataException trying to do the conversion and the call stack has no indication that my custom type converter was ever called. This same configuration works fine if I just bring those fields over as strings and don't try to use the custom type converter. =20 I have the same problem if I use the tags with object properties (instead of the constructor above). =20 Anyone know what I am doing wrong here? =20 Tony ------_=_NextPart_001_01C7C94E.A3F7580C Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

I am = trying to implement a custom type handler in my project.  I have followed the documentation and the existing example in the NUnit = tests.

 

Here is = my type converter class:

 

<><><><><><> 

 

public = class CharBoolHandlerCallback : ITypeHandlerCallback

{

    private const string DB_TRUE_VAL =3D = @"Y";

    private const string DB_FALSE_VAL =3D = @"N";

 

     public object ValueOf(string nullValue)

     {

        if (DB_TRUE_VAL.Equals(nullValue, StringComparison.OrdinalIgnoreCase)) =

           &= nbsp;    return true;

        else if (DB_FALSE_VAL.Equals(nullValue, = StringComparison.OrdinalIgnoreCase))

           &= nbsp;    return false;

           else

            throw new = DataMapperException();

     }

 

     public object GetResult(IResultGetter getter)

     {

           if (getter.Value =3D=3D null || getter.Value =3D=3D DBNull.Value) =

            throw new DataMapperException();

 

           string dbVal =3D Convert.ToString(getter.Value);

 

        if (DB_TRUE_VAL.Equals(dbVal, StringComparison.OrdinalIgnoreCase)) =

           &= nbsp;    return true;

        else if (DB_FALSE_VAL.Equals(dbVal, StringComparison.OrdinalIgnoreCase)) =

           &= nbsp;    return false;

           else

            throw new DataMapperException();

    }

 

     public void SetParameter(IParameterSetter setter, object = parameter)

     {

           setter.Value =3D Convert.ToBoolean(parameter) ? DB_TRUE_VAL : = DB_FALSE_VAL;

     }

 

    public object NullValue

    {

        get { throw new InvalidCastException(); }

    }

}

 

<><><><><><> 

 

I have = the following in my main sqlmap.config:

 

<><><><><><> 

 

<alias>

  = <typeAlias alias=3D"YesNoToBool" = type=3D"Namespace.CharBoolHandlerCallback, AssemblyName" />

</alias>

 

<typeHandlers>

  <typeHandler type=3D"bool" dbType=3D"Varchar" = callback=3D"YesNoToBool"/>

</typeHandlers>

 

<><><><><><> 

 

And my = result map looks like:

 

<><><><><><> 

 

<resultMaps>

  = <resultMap id=3D"EquipmentTypeResult" = class=3D"EquipmentTypeClass">

    <constructor>

      <argument = argumentName=3D"equipmentTypeId" column=3D"EQUIPMENT_TYPE_ID" />

      <argument = argumentName=3D"description" column=3D"DESCRIPTION" />

      <argument = argumentName=3D"createdUser" column=3D"CREATED_USERNAME"

           &= nbsp;    select=3D"GetUserByName"/>

      <argument = argumentName=3D"createdDate" column=3D"CREATED_DATE" />

      <argument = argumentName=3D"updatedUser" column=3D"UPDATED_USERNAME"

           &= nbsp;    select=3D"GetUserByName"/>

      <argument = argumentName=3D"updatedDate" column=3D"UPDATED_DATE" />

      <argument argumentName=3D"active" column=3D"ACTIVE"

           &= nbsp;    type=3D"bool" = dbType=3D"Varchar"/>

      <argument argumentName=3D"legacy" column=3D"LEGACY"

           &= nbsp;    type=3D"bool" = dbType=3D"Varchar"/>

    </constructor>

  </resultMap>

</resultMaps>

 

<><><><><><> 

 

All of my = iBATIS configuration loads.  However, when I try to get an object = instance, iBATIS throws a SqlDataException trying to do the conversion and the = call stack has no indication that my custom type converter was ever called.  = This same configuration works fine if I just bring those fields over as = strings and don’t try to use the custom type converter.

 

I have the same problem if I use the <result> = tags with object properties (instead of the constructor = above).

 

Anyone = know what I am doing wrong here?

 

Tony

------_=_NextPart_001_01C7C94E.A3F7580C--