天天看點

mybatis多表查詢時,怎麼添加别的表的屬性

使用association 屬性

column是資料庫表中的字段名,property是映射為對象的屬性名

<resultMap id="BaseResultMap" type="com.bean.Gradetable">
    <id column="gid" jdbcType="INTEGER" property="gid" />
    <result column="uid" jdbcType="INTEGER" property="uid" />
    <result column="math" jdbcType="INTEGER" property="math" />
    <result column="chinese" jdbcType="INTEGER" property="chinese" />
    <result column="english" jdbcType="INTEGER" property="english" />
    <result column="state" jdbcType="INTEGER" property="state" />
    <association property="usertable" javaType="com.bean.Usertable">
      <result column="uname" jdbcType="VARCHAR" property="uname" />
    </association>
  </resultMap>