0
Spring + JPA 애플리케이션이 있습니다. 예외가 미래에 발생했을 때 나는 데이터베이스 변경을 롤백 할나중에 예외를 throw 할 때 트랜잭션을 롤백 할 수 있습니까?
@Transactional(rollbackFor = Exception.class)
public MyEntity execute(MyEntity entity) {
//database operations
em.persist(entity);
Executors.newSingleThreadExecutor().submit(() -> {
//long calculations
if (errorOccurs)
throw new RuntimeException("Rollback transaction");
});
return entity;
}
: 내 서비스는 일부 데이터베이스 지속성 작업 및 비동기 긴 계산을 수행합니다. 내가 어떻게 해?
나를 위해, 트랜잭션에서의 긴 계산은 분명히 나쁜 생각입니다. –
내가 틀릴 수도 있지만 해결책을 찾기 위해 AOP를 보았습니까? – CKing