Mybatis多表查询字段映射不到实体类属性

今天使用查询语句多表查询的时候,查询字段始终映射不到实体类属性。
下面是sql语句。

 <select id="searchTaskByUser" resultMap="BaseResultMap">
    select t.id,t.name,title,cip,la.name as language,li.name as literatureTypes,publisher,status,salary,insti.username,insti.org,end_task_time from task t
    LEFT JOIN dic_language la ON t.language=la.id
    LEFT JOIN dic_literature li ON t.literature_types=li.id
    LEFT JOIN (select u.id,u.institution_id,u.name as username,i.name as org from user u
    LEFT JOIN institution i ON u.institution_id=i.id) insti ON insti.id=t.cata_user_id

实体类和列名都配置了属性映射,后来通过将实体类属性改为数据中表的列名解决问题。

 <select id="searchTaskByUser" resultMap="BaseResultMap">
    select t.id,t.name,title,cip,la.name as language,li.name as literature_types,publisher,status,salary,insti.username as cata_user_id,insti.org as org_id,end_task_time from task t
    LEFT JOIN dic_language la ON t.language=la.id
    LEFT JOIN dic_literature li ON t.literature_types=li.id
    LEFT JOIN (select u.id,u.institution_id,u.name as username,i.name as org from user u
    LEFT JOIN institution i ON u.institution_id=i.id) insti ON insti.id=t.cata_user_id

看来一段时间不写sql都忘了咋玩了。。。

你可能感兴趣的:(mybatis,mybatis)