작성
·
272
답변 2
1
0
EntityManagerFactory entityManagerFactory = Persistence.createEntityManagerFactory("default");
try(EntityManager entityManager = entityManagerFactory.createEntityManager()){
...
}
https://mvnrepository.com/artifact/jakarta.persistence/jakarta.persistence-api/3.1.0
jakarta.persistence-api 3.x 버전에는 EntityManager가 AutoCloseable을 지원하고 있습니다.
참고하시면 좋을꺼 같아서 올립니다.
감사합니다.
https://deeds-not-words.tistory.com/entry/JPA-EntityManager-AutoClosable-%EA%B5%AC%ED%98%84-%EA%B4%80%EB%A0%A8