@ExtendWith(SpringExtension.class)
@SpringBootTest(classes = KkApplication.class)
@ActiveProfiles("test")
public abstract class SpringTestSupport {
}

- 보통 spring data를 이용하면 영속성 컨텍스트의 생명주기는 트랜잭션의 유지시간과 동일함.
- exception이 발생하여 롤백 시 트랜잭션이 닫히면서 자연스럽게 영속성 컨텍스트도 닫힌다. 문제 발생할 여지 없음
- OSIV처럼 영속성 컨텍스트의 생명주기가 트랜잭션보다 길 때 발생 할 수 있는 문제점.
- 데이터베이스에는 데이터가 반영되지 않았지만 영속성 컨텍스트에는 데이터가 잔류 되어있다.
- spring frame work에서는 다음과 같은 방법으로 문제를 해결한다.
- 트랜잭션 롤백 시 entityManager.clear()를 호출하여 영속성 컨텍스트를 초기화한다.
관련 코드
- classpath(resource디렉토리 밑)에 logback-spring.xml파일이 있으면 Boot가 설정파일을 읽어감.
- logback-spring.xml파일이 없다면 .yml(.properties)파일의 설정을 보게됨.
설정시 특징
<appender name="privateLogAppender" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${LOG_PATH}/private.${port:-default}.log</file>
Chunk-oriented processing is not the only way to process in a Step. What if a Step must consist as a simple stored procedure call? You could implement the call as an ItemReader and return null after the procedure finishes, but it is a bit unnatural since there would need to be a no-op ItemWriter. Spring Batch provides the TaskletStep for this scenario.
The Tasklet is a simple interface that has one method, execute, which will be a called repeatedly by the TaskletStep until it either returns RepeatStatus.FINISHED or throws an exception to signal a failure. Each call to the Tasklet is wrapped in a transaction. Tasklet implementors might call a stored procedure, a script, or a simple SQL update statement
- example code
In Spring Batch, a Job is simply a container for Steps. It combines multiple steps that belong logically together in a flow and allows for configuration of properties global to all steps, such as restartability.
The job configuration contains
- The simple name of the job
- Definition and ordering of Steps