public class Good {
private int id;
private String name;
private int startprice;
private Date updatetime;
private Date deadline;
private String description;
private String uri;
private int currentprice;
private Category category;}
<resultMap type="entity.Good" id="good">
<id property="id" column="g_id"/>
<result property="name" column="g_name"/>
<association property="category" resultMap="categoryNS.category"></association>
</resultMap>
表中其它字段名和实体中的字段名是一样的,我省略不写,显示结果发现其它属性没有被反射进去。
public class User {
private int id;
private String name;
private String password;
private String sex;
private String age;
private String tel;}
而对于User这个实体
<resultMap type="entity.User" id="user">
<id property="id" column="u_id"/>
<result property="name" column="u_name"/>
<result property="password" column="u_password"/>
</resultMap>
我把resultMap中属性名和表中字段名相同省略了,发现Mybatis会把属性给反射进去
为什么有时候会反射进去,有时候不会反射进去呢,小白求教,刚学Mybatis。
<association property="category" resultMap="categoryNS.category"></association>和这个result映射有关系吗?