ibatis-user-cs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Troy Gaines" <tjg...@gmail.com>
Subject ResultMap
Date Sat, 23 Feb 2008 22:07:08 GMT
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="1.0" encoding="utf-8"?>
<sqlMapConfig
  xmlns="http://ibatis.apache.org/dataMapper"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <settings>
    <setting useStatementNamespaces="true"/>
    <setting validateSqlMap="true"/>
    <setting cacheModelsEnabled="true"/>
  </settings>
  <providers resource="providers.config"/>
  <database>
    <provider name="OleDb2.0"/>
    <dataSource name="jobTrackDataSource" connectionString="Provider=
Microsoft.Jet.OLEDB.4.0;Data Source=JobTrack.mdb"/>
  </database>
  <alias>
    <typeAlias alias="PhoneType" type="
TGaines.Model.Dao.Ibatis.PhoneTypeHandlerCallback,TGaines.Model"/>
*    <typeAlias alias="StateType" type="
TGaines.Model.Dao.Ibatis.StateTypeHandlerCallback,TGaines.Model"/>*
  </alias>
  <typeHandlers>
    *<typeHandler type="state" dbType="varchar" callback="StateType"/>
*    <typeHandler type="phone" dbType="varchar" callback="PhoneType"/>
  </typeHandlers>
  <sqlMaps>
    <sqlMap resource="Customer.xml"/>
  </sqlMaps>
</sqlMapConfig>

*<!-- SQL Map Xml (Customer.xml) -->*
<?xml version="1.0" encoding="UTF-8" ?>
<sqlMap namespace="Customer"
xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
  <alias>
    <typeAlias alias="Customer" type="TGaines.JobTrack.Model.Customer,
TGaines.JobTrack" />
  </alias>
  <resultMaps>
    <resultMap id="CustomerResult" class="Customer">
      <result property="Id" column="ID" type="int" dbType="Int"/>
      <result property="LastName" column="LAST_NAME" type="string"
dbType="varchar"/>
      <result property="FirstName" column="FIRST_NAME" type="string"
dbType="varchar"/>
      <result property="MiddleName" column="MIDDLE_NAME" type="string"
dbType="varchar"/>
      <result property="BirthDate" column="BIRTH_DATE" type="System.DateTime"
dbType="dateTime"/>
      <result property="Email" column="EMAIL" type="string"
dbType="varchar"/>
      <result property="City" column="CITY" type="string" dbType="varchar"/>
      <result property="AddressLine" column="ADDRESS" type="string"
dbType="varchar"/>
      <result property="Zip" column="ZIP_CODE" type="string"
dbType="varchar"/>
      *<result property="State" column="STATE" dbType="varchar"
type="state"/>*
      <result property="WorkPhone" column="WORK_PHONE" type="phone"/>
      <result property="HomePhone" column="HOME_PHONE" type="phone"/>
      <result property="CellPhone" column="CELL_PHONE" type="phone"/>
    </resultMap>
  </resultMaps>
  <statements>
    <select id="SelectCustomer" parameterClass="string"
resultClass="Customer">
      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
      FROM CUSTOMER
      <dynamic prepend="WHERE">
        <isParameterPresent>
          ID = #value#
        </isParameterPresent>
      </dynamic>
    </select>
    <insert id="InsertCustomer" parameterClass="Customer">
      INSERT INTO CUSTOMER

(LAST_NAME,FIRST_NAME,MIDDLE_NAME,BIRTH_DATE,EMAIL,CITY,STATE,ADDRESS,ZIP_CODE,WORK_PHONE,HOME_PHONE,CELL_PHONE)

VALUES(#LastName#,#FirstName#,#MiddleName#,#BirthDate#,#Email#,#City#,#State.Abbreviation#,#AddressLine#,#Zip#,#WorkPhone.FormattedNumber#,#HomePhone.FormattedNumber#,#CellPhone.FormattedNumber#)
      <selectKey resultClass="int" type="post" property="Id">
        SELECT @@IDENTITY
      </selectKey>
    </insert>
    <update id="UpdateCustomer" parameterClass="Customer">
      UPDATE CUSTOMER
      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#
      WHERE ID = #Id#
    </update>
    <delete id="DeleteCustomer" parameterClass="string">
      DELETE FROM CUSTOMER
      WHERE ID = #value#
    </delete>
  </statements>
</sqlMap>

Mime
View raw message