카테고리 없음

4. Spring delete 처리

Handy Smurf 2020. 9. 9. 10:15

org.zerock.mapper; > BoardMapper

1. public int delete (Long bno);

package org.zerock.mapper;

import java.util.List;

import org.zerock.domain.BoardVO;
import org.apache.ibatis.annotations.Select;

public interface BoardMapper {

//		@Select("select * from tbl_board where bno > 0") //전체 리스트를 가지고 온다. 2.setter 주석처리
		public List<BoardVO> getList();
		
		public void insert(BoardVO board);
		
		public void insertSelectKey(BoardVO board);
		
		public BoardVO read(Long bno);
		
		public int delete (Long bno);
}

2. BoardMapper.xml

 

<delete id="delete">
  	delete from tbl_board where bno = #{bno}
</delete>
  

3.BoardMapperTests

	@Test
	 public void testDelete() {

		 log.info("Delete count: " + mapper.delete(3L));
		
	}

4. 결과 확인

 

INFO : org.springframework.test.context.support.DefaultTestContextBootstrapper - Loaded default TestExecutionListener class names from location [META-INF/spring.factories]: [org.springframework.test.context.web.ServletTestExecutionListener, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener, org.springframework.test.context.support.DependencyInjectionTestExecutionListener, org.springframework.test.context.support.DirtiesContextTestExecutionListener, org.springframework.test.context.transaction.TransactionalTestExecutionListener, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener]
INFO : org.springframework.test.context.support.DefaultTestContextBootstrapper - Using TestExecutionListeners: [org.springframework.test.context.web.ServletTestExecutionListener@279fedbd, org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener@b3ca52e, org.springframework.test.context.support.DependencyInjectionTestExecutionListener@45c7e403, org.springframework.test.context.support.DirtiesContextTestExecutionListener@2925bf5b, org.springframework.test.context.transaction.TransactionalTestExecutionListener@710f4dc7, org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener@1ff4931d]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from URL [file:src/main/webapp/WEB-INF/spring/root-context.xml]
INFO : org.springframework.context.support.GenericApplicationContext - Refreshing org.springframework.context.support.GenericApplicationContext@186f8716: startup date [Wed Sep 09 10:10:37 KST 2020]; root of context hierarchy
INFO : org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor - JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
INFO : com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Starting...
INFO : com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Start completed.
INFO : org.zerock.mapper.BoardMapperTests - Delete count: 1
INFO : org.springframework.context.support.GenericApplicationContext - Closing org.springframework.context.support.GenericApplicationContext@186f8716: startup date [Wed Sep 09 10:10:37 KST 2020]; root of context hierarchy
INFO : com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown initiated...
INFO : com.zaxxer.hikari.HikariDataSource - HikariPool-1 - Shutdown completed.