List Info

Thread: ResultMap




ResultMap
user name
2008-02-23 16:07:08
I am trying to define a custom type handler for a State object using 1.6.1. 
 
I keep on getting the following error:  IBatisNet.Common.Exceptions.ConfigurationException : Error registering TypeHandler class "StateType" for handling .Net type "state" and dbType "varchar". Cause: Could not load type from string value 'state'.
  ----> System.TypeLoadException : Could not load type from string value 'state'. ;    
 
I have posted the SqlMapConfig.xml file and the actual mapping file. ; I have highlighted the relevant statements.  I'm sure they are in the right assembly as I have verified this though Reflector and through code. ; Does anyone know why I'm getting this message?  Thanks in advance!      
 
<!-- SQL Map Config (SqlMapConfig.xml) -->
<?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?>
<sqlMapConfig
 ; xmlns=&quot;http://ibatis.apache.org/dataMapper"
  xmlnssi="http://www.w3.org/2001/XMLSchema-instance&quot;>
  <settings>
&nbsp; &nbsp; <setting useStatementNamespaces="true"/>;
 &nbsp;  <setting validateSqlMap="true"/>
   ; <setting cacheModelsEnabled=&quot;true&quot;/>
  </settings>
  <providers resource=&quot;providers.config&quot;/>
  <database>
&nbsp; &nbsp; <provider name=";OleDb2.0&quot;/>
&nbsp;   <dataSource name=";jobTrackDataSource&quot; connectionString=&quot;Provider=Microsoft.Jet.OLEDB.4.0;Data Source=JobTrack.mdb&quot;/>
  </database>
  <alias&gt;
 &nbsp;  <typeAlias alias=&quot;PhoneType" type=";TGaines.Model.Dao.Ibatis.PhoneTypeHandlerCallback,TGaines.Model&quot;/>
  ;  <typeAlias alias=&quot;StateType" type=";TGaines.Model.Dao.Ibatis.StateTypeHandlerCallback,TGaines.Model&quot;/>&nbsp;  
  </alias>
  <typeHandlers>
  <typeHandler type=";state"; dbType=&quot;varchar&quot; callback=&quot;StateType"/&gt;
   ; <typeHandler type=";phone"; dbType=&quot;varchar&quot; callback=&quot;PhoneType"/&gt;
 ; </typeHandlers>
  <sqlMaps>
 ; &nbsp; <sqlMap resource=&quot;Customer.xml";/>
&nbsp; </sqlMaps>
</sqlMapConfig>
&nbsp;
&lt;!-- SQL Map Xml (Customer.xml) -->
<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; ?>
<sqlMap namespace="Customer"
xmlns="
http://ibatis.apache.org/mapping"
xmlnssi="
http://www.w3.org/2001/XMLSchema-instance" >
 ; <alias&gt;
 &nbsp;  <typeAlias alias=&quot;Customer&quot; type=";TGaines.JobTrack.Model.Customer,TGaines.JobTrack" />
&nbsp; </alias> &nbsp;
  <resultMaps>
&nbsp; &nbsp; <resultMap id="CustomerResult" class=&quot;Customer&quot;>
&nbsp;   ;  <result property=&quot;Id&quot; column=&quot;ID" type=";int" dbType=&quot;Int";/>
&nbsp; &nbsp;   <result property=&quot;LastName" column=&quot;LAST_NAME" type=";string&quot; dbType=&quot;varchar&quot;/>
  ; &nbsp;  <result property=&quot;FirstName" column=&quot;FIRST_NAME" type=";string&quot; dbType=&quot;varchar&quot;/>
 &nbsp; &nbsp;  <result property=&quot;MiddleName" column=&quot;MIDDLE_NAME" type=";string&quot; dbType=&quot;varchar&quot;/>
  ; &nbsp;  <result property=&quot;BirthDate" column=&quot;BIRTH_DATE" type=";System.DateTime" dbType=&quot;dateTime"/>
 &nbsp; &nbsp;  <result property=&quot;Email&quot; column=&quot;EMAIL&quot; type=";string&quot; dbType=&quot;varchar&quot;/>
  ; &nbsp;  <result property=&quot;City&quot; column=&quot;CITY&quot; type=";string&quot; dbType=&quot;varchar&quot;/>
 &nbsp; &nbsp;  <result property=&quot;AddressLine" column=&quot;ADDRESS&quot; type=";string&quot; dbType=&quot;varchar&quot;/>
  ; &nbsp;  <result property=&quot;Zip&quot; column=&quot;ZIP_CODE" type=";string&quot; dbType=&quot;varchar&quot;/>
 &nbsp; &nbsp;  <result property=&quot;State&quot; column=&quot;STATE&quot; dbType=&quot;varchar&quot; type=";state";/>
&nbsp; &nbsp; &nbsp; <result property=&quot;WorkPhone" column=&quot;WORK_PHONE" type=";phone";/>
&nbsp; &nbsp;   <result property=&quot;HomePhone" column=&quot;HOME_PHONE" type=";phone";/>
&nbsp; &nbsp; &nbsp; <result property=&quot;CellPhone" column=&quot;CELL_PHONE" type=";phone";/>
&nbsp; &nbsp; </resultMap>
  </resultMaps>
&nbsp; <statements>
 &nbsp;  <select id="SelectCustomer" parameterClass="string"; resultClass="Customer">
   ; &nbsp; SELECT ID AS Id,LAST_NAME AS LastName,FIRST_NAME AS FirstName,MIDDLE_NAME AS MiddleName,BIRTH_DATE AS BirthDate,EMAIL AS Email,CITY AS City,ADDRESS AS AddressLine,ZIP_CODE AS Zip,STATE as State,WORK_PHONE as WorkPhone,HOME_PHONE as HomePhone,CELL_PHONE as CellPhone
 &nbsp; &nbsp;  FROM CUSTOMER
&nbsp;   ;  <dynamic prepend=&quot;WHERE&quot;>
&nbsp; &nbsp;   ;  <isParameterPresent>
 ; &nbsp; &nbsp; &nbsp; &nbsp; ID = #value#
&nbsp; &nbsp;   ;  </isParameterPresent>
&nbsp; &nbsp; &nbsp; </dynamic>
&nbsp; &nbsp; </select>
&nbsp; &nbsp; <insert id="InsertCustomer" parameterClass="Customer&quot;>
&nbsp; &nbsp; &nbsp; INSERT INTO CUSTOMER
&nbsp;   ;  (LAST_NAME,FIRST_NAME,MIDDLE_NAME,BIRTH_DATE,EMAIL,CITY,STATE,ADDRESS,ZIP_CODE,WORK_PHONE,HOME_PHONE,CELL_PHONE)
 ; &nbsp; &nbsp; VALUES(#LastName#,#FirstName#,#MiddleName#,#BirthDate#,#Email#,#City#,#State.Abbreviation#,#AddressLine#,#Zip#,#WorkPhone.FormattedNumber#,#HomePhone.FormattedNumber#,#CellPhone.FormattedNumber#)
&nbsp;   ;  <selectKey resultClass="int" type=";post" property=&quot;Id&quot;>
&nbsp; &nbsp;   ;  SELECT IDENTITY
&nbsp;   ;  </selectKey>
&nbsp; &nbsp; </insert>
 ; &nbsp; <update id="UpdateCustomer" parameterClass="Customer&quot;>
&nbsp; &nbsp; &nbsp; UPDATE CUSTOMER
&nbsp;   ;  SET LAST_NAME=#LastName#,FIRST_NAME=#FirstName#,MIDDLE_NAME=#MiddleName#,BIRTH_DATE=#BirthDate#,EMAIL=#Email#,CITY=#City#,STATE=#State.Abbreviation#,ADDRESS=#AddressLine#,ZIP_CODE=#Zip#,WORK_PHONE=#WorkPhone.FormattedNumber#,HOME_PHONE=#HomePhone.FormattedNumber#,CELL_PHONE=#CellPhone.FormattedNumber#
   ; &nbsp; WHERE ID = #Id#
 ; &nbsp; </update>
 ; &nbsp; <delete id="DeleteCustomer" parameterClass="string";>
 ; &nbsp; &nbsp; DELETE FROM CUSTOMER
&nbsp;   ;  WHERE ID = #value#
&nbsp; &nbsp; </delete>
 ; </statements>
</sqlMap>
Re: ResultMap
user name
2008-02-24 06:14:10
A typeHandler is a relation between a dotnet primitive type (int, string....) and a dbtype so your config you be somelike
<typeHandler type=";string&quot; dbType=&quot;varchar&quot; callback=&quot;StateType"/&gt;


--
Cheers,
Gilles
RE: ResultMap
user name
2008-02-24 07:34:32

I keep removing my email address from this group but I start getting emails after a few weeks. Can you check on this for me?

 

Thanks

 

From: Gilles Bayon [mailto:ibatis.netgmail.com]
Sent: Sunday, February 24, 2008 5:14 AM
To: user-csibatis.apache.org
Subject: Re: ResultMap

 

A typeHandler is a relation between a dotnet primitive type (int, string....) and a dbtype so your config you be somelike
<typeHandler type=";string&quot; dbType="varchar" callback=&quot;StateType"/&gt;


--
Cheers,
Gilles

[1-3]

about | contact  Other archives ( Real Estate discussion Medical topics )