Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- tibero
- LOG4J
- kubectl
- JavaScript
- gson
- BPMN
- dbeaver
- Linux
- Windows
- useEffect
- IntelliJ
- VSCode
- database
- mybatis
- Spring
- SAP
- nodejs
- MySQL
- log4j2
- maven
- nginx
- springboot
- Java
- JPA
- Git
- react
- gradle
- NCP
- Kubernetes
- docker
Archives
- Today
- Total
목록EntityManagerFactoryUtils (1)
두 손끝의 창조자
현재 스레드의 EntityManager 가져오기
EntityManagerFactory는 DataSource와 연관되어 있다. 스프링 환경에서 사용하는 경우 EntityManagerFactory는 빈으로 등록해서 사용하는게 효율적이라 등록 후 사용중이라면 ApplicationContext에서 Factory를 가져올 수 있다. @Transactional 로 트랜잭션 관리를 한다면 @PersistentContext 애노테이션으로 쉽게 현재 스레드의 EntityManager를 가져올 수 있다. @PersistentContext EntityMager em; 그러나 트랜젝션을 직접 관리한다면 아래 방법으로 가져올 수 있다. EntityManager em = EntityManagerFactoryUtils.getTransactionalEntityManager(emf);
JPA
2022. 7. 4. 14:53