`
hua04104
  • 浏览: 248821 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Cause: No type handler could be found to map the property 'reporter' to the colu

阅读更多
在做根据ID查询一个带有外键的主表类时,如果在映射文件方法里返回结果使用相应类,则会报此种错误:Cause: com.ibatis.sqlmap.client.SqlMapException: No type handler could be found to map the property 'reporter' to the column 'reporter'.  One or both of the types, or the combination of types is not supported.

解决办法:使用resultMap。


错误代码:
<select id="selectPetitonLetterById" parameterClass="int" resultClass="PetitionLetter">
  	select * from t_petitionletter where id = #id#
  </select>


正确代码:
<resultMap id="PetitionLetterResult" class="PetitionLetter">
    <result property="id" column="id"/>
    <result property="identifier" column="identifier"/>
    <result property="reporter" column="reporter" select="selectReporter"/>
    <result property="letterInformation" column="letterInformation" select="selectLetterInformation"/>
    <result property="supervision" column="supervision" select="selectSupervision"/>
    <result property="processFlow" column="processFlow" select="selectProcessFlow"/>
  </resultMap>

<select id="selectPetitonLetterById" parameterClass="int" resultMap="PetitionLetterResult">
select * from t_petitionletter where id = #id#
  </select>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics