CS study/jpa 및 Hibernate (2) 썸네일형 리스트형 EntityManager와 @PersistenceContext (24.05.23) EntityManager는 Bean으로 관리되는 싱글톤 객체이지만, 이것 자체를 사용할 수는 없다. 그 이유는 생성자 주입으로 이것을 사용한다고 해도, 여러 클래스에서 공유항 사용한다면 트랜잭션 간 내부 데이터가 꼬일 가능성이 높기 때문이다. (데이터 중복 및 무결성에 문제)@PersistenceContext를 사용한다면 이 EntityManager의 Bean 객체의 '프록시'를 만들게 된다. 각각의 트랜잭션마다 이 프록시 객체를 할당함으로써, 여러 트랜잭션이 동시에 실행되더라도 EntityManager 내부에서 관리되는 데이터의 무결성을 보장할 수 있게 된다. 각각의 트랜잭션이 독립적인 EM 프록시를 할당받기 때문이다.정리EntityManager는 Bean으로 관리되는 싱글톤 객체이지만, 이것 자체를 .. QueryProjection (24.05.03) 보호되어 있는 글입니다. 이전 1 다음