• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

updateProfile에 영속성컨텍스트

20.08.31 21:57 작성 조회수 157

0

안녕하세요. 

updateProfile 메소드 내에 account 객체를 persistence로 만드는 방법과 관련해서 아래 소스와 같이 작성했는데요.

제가 생각한 것은 Id로 조회를 한 객체는 Persistence 상태이고, 값을 수정하면 update가 될것이라고 생각해서 작성했는데 update가 되지 않아 원인을 여쭤보고자 질문남깁니다.

답변 부탁드립니다. 감사합니다.

public void updateProfile(Account account, Profile profile) {
	Optional<Account> byId = accountRepository.findById(account.getId());
	Account reAccount = byId.get();
	reAccount.setBio(profile.getBio());
	reAccount.setUrl(profile.getUrl());
	reAccount.setOccupation(profile.getOccupation());
	reAccount.setLocation(profile.getLocation());
}

답변 2

·

답변을 작성해보세요.

0

parkht님의 프로필

parkht

질문자

2020.09.02

안녕하세요. @Transactional을 적용하니까 select 후에 update되는 것을 확인했습니다. 답변 감사합니다.

0

이 코드만 봐서는 알기가 어려운데요. 저 코드에 @Transactional이 적용되어 있나요?