mybatis查询的结果只拿到了id,其他属性未获取到

错误示范:
mapper.xml

  <sql id="BaseColumnList">
        id,create_by,create_time,update_by,update_time,delete_flag,import_flag,company_id,etab_code,etab_desc,etab_type,etab_unitid,etab_deptid
        ,etab_postid,etab_pernum,etab_isctrl,status,etab_sdate,etab_edate,comment,etab_takeupsum
    </sql>
    <select id="geyPostByName" resultType="com.hrocloud.znjs.orgemp.model.OrgEatabinfo">
        SELECT 
        <include refid="BaseColumnList" />
        FROM org_eatabinfo as o1,org_post as o2
        where  o1.delete_flag=0 and o2.delete_flag=0 and o1.etab_postid=o2.id and o2.post_cname like concat('%',#{postName},'%');
    </select>

应该为

  <sql id="BaseColumnList">
        id,create_by,create_time,update_by,update_time,delete_flag,import_flag,company_id,etab_code,etab_desc,etab_type,etab_unitid,etab_deptid
        ,etab_postid,etab_pernum,etab_isctrl,status,etab_sdate,etab_edate,comment,etab_takeupsum
    </sql>
    
    <resultMap id="BaseResultMap" type="com.hrocloud.znjs.orgemp.model.OrgEatabinfo">
        <id column="id" jdbcType="BIGINT" property="id"/> 
        <result column="create_by" jdbcType="BIGINT" property="createBy"/> 
        <result column="create_time" jdbcType="DATE" property="createTime"/> 
        <result column="update_by" jdbcType="BIGINT" property="updateBy"/> 
        <result column="update_time" jdbcType="DATE" property="updateTime"/> 
        <result column="delete_flag" jdbcType="TINYINT" property="deleteFlag"/> 
        <result column="import_flag" jdbcType="TINYINT" property="importFlag"/> 
        <result column="company_id" jdbcType="BIGINT" property="companyId"/> 
        <result column="etab_code" jdbcType="VARCHAR" property="etabCode"/> 
        <result column="etab_desc" jdbcType="VARCHAR" property="etabDesc"/> 
        <result column="etab_type" jdbcType="VARCHAR" property="etabType"/> 
        <result column="etab_unitid" jdbcType="BIGINT" property="etabUnitid"/> 
        <result column="etab_deptid" jdbcType="BIGINT" property="etabDeptid"/> 
        <result column="etab_postid" jdbcType="BIGINT" property="etabPostid"/> 
        <result column="etab_pernum" jdbcType="DECIMAL" property="etabPernum"/>
        <result column="etab_isctrl" jdbcType="TINYINT" property="etabIsctrl"/> 
        <result column="status" jdbcType="VARCHAR" property="status"/>
        <result column="etab_sdate" jdbcType="DATE" property="etabSdate"/> 
        <result column="etab_edate" jdbcType="DATE" property="etabEdate"/> 
        <result column="comment" jdbcType="VARCHAR" property="comment"/>
        <result column="etab_takeupsum" jdbcType="VARCHAR" property="etabTakeupsum"/>
    </resultMap> 
    
   <select id="geyPostByName" resultMap="BaseResultMap">
        SELECT 
        <include refid="BaseColumnList" />
        FROM org_eatabinfo as o1,org_post as o2
        where  o1.delete_flag=0 and o2.delete_flag=0 and o1.etab_postid=o2.id and o2.post_cname like concat('%',#{postName},'%');
    </select>

猜你喜欢

转载自blog.csdn.net/JavaSupeMan/article/details/111316171