使用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>
本文详细解析了 MyBatis 中 resultMap 的 association 属性使用方法,通过具体示例展示了如何将数据库表字段与 Java 对象属性进行映射,特别关注了如何通过 association 实现一对多关系的数据映射。
4179

被折叠的 条评论
为什么被折叠?



