Transactional

    [Querydsl] n시간 이전 데이터 삭제

    @Transactional fun exampleMethod(): Long { var date = LocalDateTime.now() date = date.minusHours(1) return queryFactory .delete(table_name) .where(table_name.updatedAt.lt(date)) .execute() } 위 코드는 아래와 같이 작동됩니다. 현재 시간이 2021년 11월 20일 10시 5분 이라면, DELETE FROM `table_name` WHERE `table_name`.updatedAt < '2021-11-20 09:05:00' 위와 같은 쿼리문이 작성되는 것입니다. 쿼리 진행 후 삭제가 된 데이터의 갯수를 리턴하도록 되어 있습니다.