Auditing transaction
미해결
실전! 스프링 데이터 JPA
안녕하세요, auditing 강의를 듣고 적용해보았습니다. 게시글을 처음에 만들때 원하는 값들이 잘 들어가지만 게시글을 수정하여 다시 저장할 경우audit 부분에서 createdBy, modifiedBy 를 못가져오면서 transaction 에러를 냅니다..! 혹시 실무에 적용하기 위해 추가로 적용해야 할 부분이 있을까요? 아마 AuditorAwareImpl에서 @Autowired MemberRepository memberRepository; 부분이 이상한 것 같은데...이유는 모르겠습니다 ㅠ_ㅠ public class AuditorAwareImpl implements AuditorAware < Long > { @ Autowired MemberRepository memberRepository; @ Override public Optional < Long > getCurrentAuditor () { Authentication authentication = SecurityContextHolder . getContext (). getAuthentication (); if ( null == authentication || ! authentication. isAuthenticated ()) { return null ; } DefaultOAuth2User principal = ( DefaultOAuth2User ) authentication. getPrincipal (); String email = ( String ) principal. getAttributes (). get ( "email" ); if (email == null ){ return null ; } Member member = memberRepository. findByEmail (email). orElse ( null ); if (member == null ){ return null ; } return Optional . of (member. getId ()); } }
- audit
- spring
- spring-boot
- JPA
- java





