mybatis嵌套查询,resultMap不匹配,大神帮我看看

这是实体类:
private int employeeId;
private String employeeNum;
private String employeePass;
private String personName;
private String employeeGender;
private Positions employeePosition;
private Department employeeDepartment;
private Site employeeSite;

这是mappper:
<resultMap type="Employee" id="employeeMap">
<id property="employeeId" column="employeeId"/>
<result property="employeeNum" column="employeeNum"/>
<result property="employeePass" column="employeePass"/>
<result property="personName" column="personName"/>
<result property="employeeGender" column="employeeGender"/>
 <association property="employeePosition" javaType="Positions" column="employeePosition" select="org.carabmer.dao.PositionsDao.positionQuery">
 <id property="positionId" column="positionId"/>
<result property="positionName" column="positionName"/>
</association>
<association property="employeeSite" javaType="Site" column="employeeSite" select="org.carabmer.dao.SiteDao.siteQuery">
<id property="siteId" column="siteId"/>
<result property="siteAddress" column="siteAddress"/>
<result property="siteUsed" column="siteUsed"/>
</association>
        <association property="employeeDepartment" javaType="Department" column="employeeDepartment" select="org.carabmer.dao.DepartmentDao.departmentQuery">
            <id property="departmentId" column="departmentId"/>
            <result property="departmentName" column="departmentName"/>
</association>
    </resultMap>


这是异常:
 No constructor found in org.carabmer.model.Employee matching [java.lang.Integer, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.Integer, java.lang.Integer, java.lang.Integer]

 按理来说返回的属性应该是department等类型,可是还是返回int类型,resultMap还不是很熟悉,大神帮我看看,急

3个回答

resultMap返回的是employeeMap,你这实体里面存在对象,需要重新写个map

qq_25070135
qq_25070135 association连接的select里返回值是对象啊
大约 3 年之前 回复

你只贴出了resultMap ,在哪儿使用resultMap,mapper对应的Dao接口,以及resultMap对应的POJO对象都没有贴出来,无法判断哎

如果单单看异常,那么可以判断的就是POJO对象的构造方法中定义出错,
你应该是自定义构造方法
构造方法不对应所导致的异常

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问