0
点赞
收藏
分享

微信扫一扫

Mapper.xml里写两表联查,遇到的错误和正确写法

十里一走马 2022-04-14 阅读 82

There is no setter for property named 'dDepartments' in 'class com.entity.Consulation'!!

出现这个我的错不是其他网友说的少写了一个字母,也不是对应的类名错误,而是在我主键的那个表多写了一个外建那个表里的一个字段!!删掉立马就好了,jsp页面就能调用出来东西了!写在主键所在的mapper.xml里!

<resultMap id="BaseResultMap" type="com.entity.Consulation" >

    <id column="consuId" property="consuId" jdbcType="INTEGER" />
    <result column="docId" property="docId" jdbcType="VARCHAR" />
    <result column="pIdentity" property="pIdentity" jdbcType="VARCHAR" />
    <result column="pName" property="pName" jdbcType="VARCHAR" />
    <result column="consuTitle" property="consuTitle" jdbcType="VARCHAR" />
    <result column="consuContent" property="consuContent" jdbcType="VARCHAR" />
    <result column="consuPic" property="consuPic" jdbcType="VARCHAR" />
    <result column="consuTime" property="consuTime" jdbcType="VARCHAR" />
    <result column="replyContent" property="replyContent" jdbcType="VARCHAR" />
    <result column="replyTime" property="replyTime" jdbcType="VARCHAR" />
    <result column="nextId" property="nextId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="byidcdMap" type="com.entity.Consulation" >

    <id column="consuId" property="docId"  />
    <result column="docId" property="consuId"  />
    <result column="pIdentity" property="pIdentity" />
    <result column="pName" property="pName"/>
    <result column="consuTitle" property="consuTitle"/>
    <result column="consuContent" property="consuContent"  />
    <result column="consuPic" property="consuPic"  />
    <result column="consuTime" property="consuTime"  />
    <result column="replyContent" property="replyContent"  />
    <result column="replyTime" property="replyTime"  />
    <result column="nextId" property="nextId" jdbcType="INTEGER" />

    <association property="doctor" javaType="com.entity.Doctor">
        <id column="docId" property="docId"  />
        <result column="dPic" property="dPic"  />
        <result column="dName" property="dName"  />
        <result column="dZc" property="dZc"  />
        <result column="dHospital" property="dHospital"  />
        <result column="dDepartments" property="dDepartments"  />
        <result column="dGood" property="dGood"  />
    </association>
</resultMap>

两表联查sql语句

select d.*,c.* from consulation c inner join doctor d on c.docId=d.docId where c.docId = #{docId};
举报

相关推荐

0 条评论