---
title: "Discussion on \"[JPA] 엔티티 equals 오버라이딩 괜찮을까?\" | Hashnode"
description: "Discussion on \"[JPA] 엔티티 equals 오버라이딩 괜찮을까?\". 최근에 한 딜레마에 빠졌다.\n레포지토리에 대한 테스트 코드를 짜고 있었는데, 확실한 DB 조회 확인을 위해 영속성 컨텍스트를 초기화(em.clear)하면서 문제가 생겼다.\n테스트에서 em.clear()을 했을 때의 예시\n@BeforeEach 에서 먼저 필드에 더미 데이터를 넣어준다. \n추후의 테스트를 편리하게 할 목적의 필드이다.\n// ...\npublic class MemberRepositoryTest {\n\n        // ...\n     ..."
url: "https://hashnode.com/posts/jpa-equals/658c1b306e3490cd27309010"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [\[JPA\] 엔티티 equals 오버라이딩 괜찮을까?](https://wonslee.hashnode.dev/jpa-equals?utm_source=hashnode&utm_medium=feed)

최근에 한 딜레마에 빠졌다. 레포지토리에 대한 테스트 코드를 짜고 있었는데, 확실한 DB 조회 확인을 위해 영속성 컨텍스트를 초기화(em.clear)하면서 문제가 생겼다. 테스트에서 em.clear()을 했을 때의 예시 @BeforeEach 에서 먼저 필드에 더미 데이터를 넣어준다. 추후의 테스트를 편리하게 할 목적의 필드이다. // ... public class MemberRepositoryTest { // ... ...

Oct 26, 2023 · 3 min read · wonslee.hashnode.dev  
Read the article

-   [#jpa](https://hashnode.com/tag/jpa)

## Written by

[Won Seok Lee](https://hashnode.com/@wonslee)

@wonslee

  
[View profile](https://hashnode.com/@wonslee)

spring

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
