JPA

    [Error] unable to evaluate the expression method threw 'org.hibernate.lazyinitia

    [Error] unable to evaluate the expression method threw 'org.hibernate.lazyinitia

    📌 오류 발생 원인Member member = memberRepository.findById(Long.valueOf(memberId)) .orElseThrow(() -> new UsernameNotFoundException("존재하지 않는 계정입니다.")); Authentication authentication = jwtProvider.getAuthentication(member);먼저, memberRepository에서 findById를 통해 Member(회원) 엔티티를 조회해온다. public Authentication getAuthentication(Member member) { MemberContext memberContext = new MemberContext(member); return new..

    [Spring] JPA N + 1 문제 발생 원인 및 해결 방안

    [Spring] JPA N + 1 문제 발생 원인 및 해결 방안

    📌 JPA N + 1 문제란?조회된 데이터 개수만큼, 연관 관계의 조회 쿼리가 추가로 발생하는 문제를 의미한다. EX) 카테고리와 게시글@Entity @NoArgsConstructor @Setter @Getter public class Board { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String title; private String content; @ManyToOne private Category category; public Board(String title, String content, Category category) { this.title = title; this.content = co..