Notice
Recent Posts
Recent Comments
Link
«   2025/05   »
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Tags more
Archives
Today
Total
관리 메뉴

기록

트랜잭션 관리 본문

JAVA

트랜잭션 관리

9400 2023. 2. 10. 17:24

root-context 추가 

 

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
                  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

 

 

 <!-- 
 트랜잭션 : 데이터베이스를 변경하기 위해 수행되어야할 논리적 단위. 여러개의 sql로 구성됨
 원자성, 일관성, 고립성(격리성), 지속성(영속성)
  -->
  <!-- 트랜잭션 관리자의 자바빈을 정의함 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource"></property>
</bean>  

<!-- 애너테이션 기반의 트랜잭션 제어를 활성화함 -->
<tx:annotation-driven/>

 

어노테이션

@Transactional 

//고객(CUS)등록  + 소유자돋차등록
	@Transactional
	@Override
	public int createPost(CusVO cusVO) {
		int result = 0;
		//1. 고객(CUS) 등록(1행)
		result= this.cusMapper.createPost(cusVO);
		
		//2. 소유자동차(CAR) 등록(N행)
		List<CarVO> carVOList = cusVO.getCarVOList();
		List<CarVO> carVOListNew = new ArrayList<CarVO>();
		
		//cusNum 최신화
		for(CarVO carVO : carVOList) {
			carVO.setCusNum(cusVO.getCusNum());
			carVOListNew.add(carVO);
		}
		
		result = result + this.cusMapper.createPostcar(carVOListNew);
		log.info("result : "+result);
		
		return result;
	}

 

알아서 트랜잭션

'JAVA' 카테고리의 다른 글

JAVA Spring security 시큐리티 설정  (0) 2023.02.13
에러페이지 예외처리하기  (0) 2023.02.10
구글차트 사용법  (0) 2023.02.10
JAVA Spring MAPPER 인터페이스 설정  (0) 2023.02.06
다음 카카오 주소검색 추가  (0) 2023.02.03
Comments