일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 29 | 30 | 31 |
- jmeter
- cassandra
- docker compose mysql
- grafana
- Airflow
- JPA
- vue.js
- Spring Open Feign
- redis
- netflix oss
- Netty
- spring boot redis
- Hibernate
- argo cd
- spring cloud
- ChannelPipeline
- spring boot
- MySQL
- Docker Compose
- Selenium
- KAFKA
- docker
- mybatis
- WebLogic
- RabbitMQ
- QueryDSL
- Redis Sentinel
- weblogic 10
- coalesce
- docker-compose
- Today
- Total
IT.FARMER
No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call 본문
No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call
아이티.파머 2022. 5. 24. 11:02EntityManager 를 이용하여 mearge 문을 사용하거나 insert를 사용할때... 다음과 같은 오류가 났다.
No EntityManager with actual transaction available for current thread - cannot reliably process 'merge' call
transaction 관련된 설정이 없다고해서 확인해보니
역시나... @Transactional 을 설정하지 않았다.
@Transactional
public <T extends AbstractAdEntity> void update(T abstractAdEntity) {
try {
entityManager.merge(abstractAdEntity);
entityManager.flush();
} catch (Exception e) {
e.printStackTrace();
} finally {
entityManager.close();
}
}
The @PersistenceContext annotation has an optional attribute type, which defaults to PersistenceContextType.TRANSACTION. This default is what you need to receive a shared EntityManager proxy. The alternative, PersistenceContextType.EXTENDED, is a completely different affair: This results in a so-called extended EntityManager, which is not thread-safe and hence must not be used in a concurrently accessed component such as a Spring-managed singleton bean. Extended EntityManagers are only supposed to be used in stateful components that, for example, reside in a session, with the lifecycle of the EntityManager not tied to a current transaction but rather being completely up to the application.
EntityManager 의 트랜젝션을 어플리케이션에서 위임해서 사용한다. 어플리케이션의 로직에 @Transaction 을 사용 할것.
https://docs.spring.io/spring-framework/docs/current/reference/html/data-access.html#transaction
'Spring > Spring Data JPA' 카테고리의 다른 글
오류- Lock wait timeout exceeded; try restarting transaction (0) | 2023.05.25 |
---|---|
found [text (Types#LONGVARCHAR)], but expecting [varchar(255) (Types#VARCHAR)] (0) | 2023.03.08 |
Hibernate(JPA) 영속성 (persistence) (0) | 2022.04.22 |
Spring Transactional 옵션 (0) | 2022.04.20 |
Composite-id class must implement Serializable (0) | 2021.11.22 |