반응형
Notice
Recent Posts
Recent Comments
Link
관리 메뉴

bro's coding

Spring.MyBatis.DB.Map 본문

[IT]/Spring

Spring.MyBatis.DB.Map

givemebro 2021. 5. 27. 11:37
반응형
	<select id="findMemberMapById" resultType="map"
		parameterType="string">
		<include refid="selectMember" />
		where id=#{value}
	</select>
	@Override
	public Map<String,String> findMemberMapById(String id) {
		return template.selectOne("member.findMemberMapById", id);
	}
package test;

import java.util.Map;
import org.kosta.model.MemberDAO;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class TestMyBatis {
	public static void main(String[] args) {
		ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spring-config.xml");
		MemberDAO dao = (MemberDAO) ctx.getBean("MemberDAO");
		Map<String, String> map = dao.findMemberMapById("java");
		// MyBatis에서 Map으로 반환할 때는 Key값이 대문
		System.out.println(map.get("ID"));
		System.out.println(map.get("PASSWORD"));
		System.out.println(map.get("NAME"));
		System.out.println(map.get("ADDRESS"));

		ctx.close();
	}
}
반응형

'[IT] > Spring' 카테고리의 다른 글

Spring.MyBatis.join.vo.resultMap  (0) 2021.05.31
Spring.MyBatis.인스턴스 객체 접근  (0) 2021.05.31
param.productNo 값 넣고 insert  (0) 2021.05.28
Spring.MyBatis.table column 명과 VO의 instance변수 명이 다른 경우  (0) 2021.05.28
Spring.MyBatis Framework  (0) 2021.05.27
Spring.MyBatis.DB사용  (0) 2021.05.26
Spring.AOP.around  (0) 2021.05.25
log4j  (0) 2021.05.24
Comments