2020import com .howWeather .howWeather_backend .global .cipher .AESCipher ;
2121import com .howWeather .howWeather_backend .global .exception .CustomException ;
2222import com .howWeather .howWeather_backend .global .exception .ErrorCode ;
23+ import jakarta .persistence .EntityManager ;
2324import org .springframework .beans .factory .annotation .Value ;
2425import org .springframework .http .HttpEntity ;
2526import org .springframework .http .HttpHeaders ;
4142@ Service
4243@ RequiredArgsConstructor
4344public class MyAccountService {
45+ private final EntityManager entityManager ;
4446 private final WeatherForecastRepository weatherForecastRepository ;
4547 private final MemberRepository memberRepository ;
4648 private final ClothingRecommendationRepository recommendationRepository ;
47- private final RecommendationService recommendationService ;
4849 private final DailyCombinationScheduler dailyCombinationScheduler ;
4950 private final AiInternalService aiInternalService ;
5051 private final RestTemplate restTemplate ;
@@ -320,6 +321,8 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
320321 }
321322
322323 log .info ("[추천 데이터 저장 완료] memberId={}" , member .getId ());
324+ recommendationRepository .flush ();
325+ entityManager .clear ();
323326 } else {
324327 List <ClothingRecommendation > existingData =
325328 recommendationRepository .findByMemberIdAndDate (member .getId (), LocalDate .now ());
@@ -339,8 +342,9 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
339342 .build ();
340343
341344 recommendationRepository .save (updatedEntity );
342- recommendationRepository .flush ();
343345 }
346+ recommendationRepository .flush ();
347+ entityManager .clear ();
344348
345349 log .info ("[기존 데이터 지역명 업데이트 완료] memberId={}" , member .getId ());
346350 }
@@ -352,6 +356,7 @@ public void saveRecommendationsInternal(Map<String, String> encryptedData, Strin
352356 throw new CustomException (ErrorCode .UNKNOWN_ERROR , "지역명 업데이트 중 오류가 발생했습니다." );
353357 }
354358 }
359+
355360 private ClothingRecommendation convertToEntityWithBuilder (ModelRecommendationResult dto , Long memberId , String regionName ) {
356361 return ClothingRecommendation .builder ()
357362 .memberId (memberId )
0 commit comments