基本的增删改

@Insert("insert into t_user values(null,#{username},#{password},#{account})")

@Delete(“delete from t_user where pk_id = #{id}”)

@Update(“update t_user set f_username=#{param1} where pk_id=#{param2}”)

简单查询

@Select(“select * from t_user where pk_id=#{id}”)

@Select(“select *from t_user”)

结果集

@Results(
value={ @Result(id=true,column=“pk_id”,property=“id”),
@Result(property=“name”,column=“f_name”)
}
)
在XML中定义结果集resultMap
@ResultMap(“结果集名字”)

关系映射

一对一

@Result(property=“myHome”,column=“lock_id”,one=@One(select=“com.lovo.mapper.HomeMapper.getHomeByLock”))

一对多

@Result(property=“keyLst”,column=“lock_id”,many=@Mnay(select=“com.lovo.mapper.KeyMapper.getKeyByLock”))

多对多

@Result(property=“courceList”,column=“student_id”,many=@Mnay(select=“com.lovo.mapper.CourceMapper.getCourceByStudent”))
04-25 20:02