//@Mapper //该接口基于hibernate
public interface EmpMap {
public Employee getEmp(Integer id);
// public Map<String,Object> getEmpName();
public void insertEmp(Employee employee);
//测试集合数据配置文件成功一次
public List<Employee> getAll();
}//配置文件
<mapper namespace="com.dream.sbmybatis.map.EmpMap">
<!--public Employee getEmp(Integer id);
public void insertEmp(Employee employee);-->
<select id="getEmp" resultType="com.dream.sbmybatis.bean.Employee">
select * from employee where id = #{id}
</select>
<!--<resultMap id="getEmpName" type="com.dream.sbmybatis.bean.Employee">
<id property="id" column="id"/>
<result property="email" column="email"/>
</resultMap>-->
<!--INSERT INTO employee('last_name','gender','email','d_id') VALUE("nima","woman","16277",1)-->
<!-- @Options(useGeneratedKeys = true,keyProperty = "id")-->
<insert id="insertEmp" >
INSERT INTO employee(last_name,gender,email,d_id) VALUE (#{lastName},#{gender},#{email},#{dId})
</insert>
<select id="getAll" resultType="com.dream.sbmybatis.bean.Employee">
select * from employee
</select>
</mapper>
//@Mapper //纯注解的方式;集合是
public interface DepMap {
/*不是$就是#*/
//返回集合数据两次
@Select("select * from department")
public List<Department> getAll();
@Select("select * from department where id=#{id}")
public Department getDepByID(Integer id);
@Delete("delete from department where id=#{id}")
public int deleteByID(Integer id);
@Options(useGeneratedKeys = true,keyProperty = "id")
@Insert("insert into department (dept_name) values(#{deptName})")
public int insert(Department department);
@Update("update department set dept_name=#{deptName} where id=#{id}")
public int upde(Department department);
// 真的是连增删改查都不用写了,只写业务逻辑
}