mytabis 연동 설정

2020. 10. 20. 11:35·개발중/Spring Boot
728x90
반응형

mytabis ~.xml 로 이렇게 기술한 코드 들을 사용하려면

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper 
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="board">	

	<insert id="add" parameterType="net.hb.crud.BoardDTO">
	   insert into hobby
	   values(hobby_seq.nextVal, #{name}, #{title}, #{content}, #{gender}, #{hobby}, #{img_file_name} )    
	</insert>
	
	<select id="selectAll" resultType="net.hb.crud.BoardDTO">
	   select rownum rn,  h.* from  hobby h 
	</select>
	
	<select id="countAll" resultType="int">
	   select count(*)  from hobby
	</select>
	
	<select id="detail" parameterType="int" resultType="net.hb.crud.BoardDTO">
	   select * from  hobby  where hobby_idx = #{data} 
	</select>
	
	<delete id="del" parameterType="int">
		delete  from  hobby  where hobby_idx = #{data} 
	</delete>
	
	
	<!--  검색및 페이징 동적쿼리문  -->
	<select id="countAllSearch"  parameterType="net.hb.crud.BoardDTO"  resultType="int" >
		select count(*) from hobby  where ${skey} like '%' || #{sval} || '%'  
	</select>
	
	<select id="selectAll789" parameterType="net.hb.crud.BoardDTO" resultType="net.hb.crud.BoardDTO">
	   select  * from  (
	     select  rownum rn, h.* ,(select count(*) from hobby_reply r where r.hobby_idx=h.hobby_idx) as rcnt from    
	      (select * from hobby  where ${skey} like '%' ||  #{sval} ||  '%'  ) h 
	   ) where rn  between #{start} and  #{end} 
	</select>
	
	<!-- selectAllTis -->
	<select id="selectAllTis" parameterType="net.hb.crud.BoardDTO"  resultType="net.hb.crud.BoardDTO">
	    select * from (
		  select  rownum rn, h.* from hobby h
		) where rn between  #{start}  and  #{end}  
	</select>
	
	<select id="selectAllDynamic"  resultType="net.hb.crud.BoardDTO">
		select * from (
		select  rownum as rn, h.* from  (
		select * from hobby 
		
		<if test="skey != null">
			<if test="skey == 'name'">
				where name like '%' || #{sval} || '%'
			</if>
			<if test="skey == 'title'">
				where title like '%' || #{sval} || '%'
			</if>
			<if test="skey == 'content'">
				where content like '%' || #{sval} || '%'
			</if>
		</if>
		   order by hobby_idx 
		  ) h
	   ) where rn between #{start} and #{end}
	</select>	
</mapper>

SqlMapConfig.xml 문서에서 설정을 해주어야 한다.

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
		
	<typeAliases>
	   <typeAlias alias="bdto"  type="net.hb.crud.BoardDTO"/>
	   <typeAlias alias="gdto"  type="net.hb.crud.GuestDTO"/>
	</typeAliases>
	
	<mappers>
		<mapper resource="config/mybatis/guest.xml"/>
		<mapper resource="config/mybatis/board.xml"/>
		<mapper resource="config/mybatis/board_reply.xml"/>
		<mapper resource="config/mybatis/login.xml"/>
	</mappers>
	
</configuration>

 

728x90
반응형

'개발중 > Spring Boot' 카테고리의 다른 글

AOP  (0) 2020.10.20
pom.xml 문서 기록  (0) 2020.10.20
db.properties  (0) 2020.10.20
Spring 을 다 고쳤을 때도 에러가 사라지지 않는다면  (0) 2020.10.20
ModelAndView 문서의 흐름  (0) 2020.10.20
'개발중/Spring Boot' 카테고리의 다른 글
  • AOP
  • pom.xml 문서 기록
  • db.properties
  • Spring 을 다 고쳤을 때도 에러가 사라지지 않는다면
Binsoo
Binsoo
내 트러블 슈팅
  • Binsoo
    정수빈 기술블로그임.
    Binsoo
  • 전체
    오늘
    어제
    • 빈수 개발자 개발 일기 (932)
      • 개발중 (634)
        • Spring Boot (95)
        • Spring Security (2)
        • Spring Batch (6)
        • Spring Boot & Redis (13)
        • Java Persistence API (JPA) (28)
        • Web (42)
        • Rest Api (7)
        • Spring Concurrency Control (3)
        • Redis (8)
        • Kubernetes (k8s) (4)
        • MYSQL (35)
        • AirFlow (15)
        • Docker (2)
        • Git (22)
        • Linux (9)
        • JSON Web Tokens (JWT) (4)
        • Troubleshooting (87)
        • Swagger (0)
        • Vue.js (52)
        • Java (74)
        • html (12)
        • C (5)
        • jQuery (15)
        • JavaServer Pages (JSP) (17)
        • Arduino (1)
        • JavaScript (35)
        • Amazon Web Services (AWS) (11)
        • Algorithm (9)
        • 참고 기능 (18)
        • mongo (2)
      • PROJECT (27)
        • 스프링부트+JPA+몽고 API 개발 (3)
        • MINI (2)
        • 게시판 (3)
        • vue 프로젝트 (1)
        • JPA 사이드 프로젝트 기록 (17)
      • TEAM STUDY (156)
        • 가상 면접 사례로 배우는 대규모 시스템 설계 기초 (8)
        • 한 권으로 읽는 컴퓨터 구조와 프로그래밍 (12)
        • NAVER DEVELOPER (4)
        • LINUX (23)
        • PYTHON (19)
        • SERVER (8)
        • 알고리즘 코딩 테스트 스터디 (31)
        • 쿠버네티스 (40)
        • 대세는 쿠버네티스 [초급~중급] (11)
      • BOOK (0)
      • 자격증 (61)
        • 리눅스 1급 - 필기 기록 (19)
        • 네트워크 관리사 (2)
        • 네트워크 관리사 2급 - 실기 기록 (21)
        • 네트워크 관리사 2급 - 필기 기록 (16)
        • 정보처리 (2)
      • 직장인 대학원 (17)
        • 기록 (1)
        • 캐글 스터디 (3)
        • R (12)
  • 블로그 메뉴

    • 홈
    • 태그
  • 링크

  • 공지사항

  • 인기 글

  • 태그

    네트워크 관리사
    네트워크 관리사 자격증
    리눅스 마스터 요약
    쿠버네티스
    Spring
    jpa
    스프링
    리눅스 마스터
    네트워크 관리사 학점
    네트워크 관리사 요약
    REST API
    리눅스 마스터 1급 요약
    springboot
    네트워크 관리사 2급
    docker
    파이썬
    redis
    git
    BackendDevelopment
    파이썬 알고리즘
    VUE
    네트워크 관리사 2급 실기
    리눅스 1급 요약
    java
    리눅스 마스터 1급 정리
    네트워크 관리사 실기
    알고리즘
    리눅스 마스터 1급
    쿠버네티스 스터디
    Git 저장소
  • 최근 댓글

  • 최근 글

  • hELLO· Designed By정상우.v4.10.4
Binsoo
mytabis 연동 설정
상단으로

티스토리툴바