69-2: Spring MyBatis parameterType

jk·2024년 4월 11일
0

kdt 풀스택

목록 보기
110/127



1. 자바에서 마이바티스(xml)로 파라미터 전달 방법은?

parameterType="path.of.the.package.and.class"



2. Dept insert 와 remove 를 구현하시오.

//code1
	@PostMapping("/register")
	public String register(DeptVO deptVO) {
		System.out.println("register()..");
		deptService.register(deptVO);
		return "redirect:/dept/list";
	}
	@GetMapping("/remove")
	public String remove(DeptVO deptVO) {
		System.out.println("remove()..");
		deptService.remove(deptVO);
		return "redirect:/dept/list";
	}
//code2
	@Override
	public void register(DeptVO deptVO) {
		System.out.println("register()..");
		deptMapper.insert(deptVO);
	}
	@Override
	public void remove(DeptVO deptVO) {
		System.out.println("remove()..");
		deptMapper.delete(deptVO);
	}
//code3
	public void insert(DeptVO deptVO);
	public void delete(DeptVO deptVO);
<!-- code4 -->
    <insert id="insert" parameterType="edu.sejong.ex.vo.DeptVO">
        <![CDATA[
        	insert into dept values (#{deptno}, #{dname}, #{loc})
        ]]>
    </insert>
    <delete id="delete" parameterType="edu.sejong.ex.vo.DeptVO">
        <![CDATA[
        	delete from dept where deptno = #{deptno}
        ]]>
    </delete>
profile
Brave but clumsy

0개의 댓글