Closed veluxer62 closed 5 months ago
YearMonth라는 자료형이 있네
JPA로 사용하려면 컨버터를 만들어야 하긴 하지만 나쁘지 않은듯
YearMonth 의 월 차이를 계산하려면 아래와 같이 하면된다.
val gap = billingMonth.until(appliedDate, ChronoUnit.MONTHS).absoluteValue
아래와 같이 repository.save에서 발생하는 에러를 try catch로 처리하려고 했을때 Flush에러를 catch에서 잡아주지 못하는 이슈가 있다.
JPA의 transactional 메커니즘 때문인것처럼 보이는데 자세히 뜯어봐야겠다.
class Service {
@Transactional
fun createDraft(billingMonth: YearMonth): List<MatchingFeeBill> {
// 생략
return try {
matchingFeeBillRepository.saveAll(bills)
} catch (e: Exception) {
// 여기로 예외가 잡히지 않음
}
}
}
class Facade {
fun createDraft(billingMonth: YearMonth): List<MatchingFeeBill> {
return try {
service.createDraft(billingMonth: YearMonth)
} catch(e: Exception) {
// 여기선 잡힘
}
}
}
Motivation
Suggestion
1