mybaties配置多个resultMap,实现返回不同的实体

id="userInfo" type="userInfo">
        <result property="userID" column="UserID" />
        <result property="loginID" column="LoginID" />
        <result property="password" column="Password" />
        <result property="isDelete" column="IsDelete" />
        <result property="isLock" column="IsLock" />
        <result property="pwdUpdateDate" column="PwdUpdateDate" />
        <result property="pwdExpiryDate" column="PwdExpiryDate" />
        <result property="pwdErrorTimes" column="PwdErrorTimes" />
        <result property="remark" column="Remark" />
        <result property="employeeID" column="EmployeeID" />
        <result property="createDate" column="CreateDate" />
        <result property="createBy" column="CreateBy" />
        <result property="modifyDate" column="ModifyDate" />
        <result property="modifyBy" column="ModifyBy" />
    


        id="userInfoEtd" type="UserInfoEtd">
        <result property="userID" column="UserID" />
        <result property="loginID" column="LoginID" />
        <result property="password" column="Password" />
        <result property="isDelete" column="IsDelete" />
        <result property="isLock" column="IsLock" />
        <result property="pwdUpdateDate" column="PwdUpdateDate" />
        <result property="pwdExpiryDate" column="PwdExpiryDate" />
        <result property="pwdErrorTimes" column="PwdErrorTimes" />
        <result property="remark" column="Remark" />
        <result property="employeeID" column="EmployeeID" />
        <result property="createDate" column="CreateDate" />
        <result property="createBy" column="CreateBy" />
        <result property="modifyDate" column="ModifyDate" />
        <result property="modifyBy" column="ModifyBy" />
        --  下面是扩展的属性,对应type已经改为扩展类-->
        <result property="positionName" column="positionName" />
    

不同的方法返回不同的实体


      --返回实体为userInfo
    <select id="getByIds" resultMap="userInfo" parameterType="ArrayList">
        select 
        ....对应resultMap="userInfo"映射的字段
        from  UserInfo

    select>


      --返回实体为userInfoEtd
    <select id="getUsersByDepartmentID" parameterType="String" resultMap="userInfoEtd">
    SELECT
        EmployeeInfo.UserID,
        DataDictionaryDetail.Value AS PositionName
        FROM
        多表联合
    select>

转载于:https://www.cnblogs.com/feiZhou/p/9344092.html

你可能感兴趣的:(mybaties配置多个resultMap,实现返回不同的实体)