-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User bounded context에서 JPA 사용하도록 수정 #348
Conversation
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
|
||
other as User | ||
|
||
return id == other.id | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
data class 가 아니고 class 면 이거 override 해줄 필요가 없지 않나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Class의 동등성 비교가 기본으로 메모리상 주소 비교일 것 같은 느낌...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Kotlin, the equals() function is inherited by all classes from the Any class. By default, the equals() function implements referential equality. However, classes in Kotlin can override the equals() function to provide a custom equality logic and, in this way, implement structural equality.
넹 그렇네요. 그럼 spring data jpa 쓰면서 other 가 Hibernate$Proxy 인 케이스도 고려해서 작성해줘야 하지 않을까요? User$Proxy 면 as User
로 다운 캐스팅하다 에러 날 것 같기도 해서 as?
로 하는건 어떤가요? proxy 면 애초에 javaClass 가 다른가? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
회사에서 이렇게 쓰고 있는데 별 문제가 없었어서... bytecode로 instrument 됐을 때 클래스가 어떻게 될지는 모르겟는데 일단 잘 동작하는 것 같긴 합니다 ㅋㅋ
DB 에 접근하는 것도 out port 로 보면 현재와 같은 레이어링이 맞는 것 같아 보이기도 하는데 JPA 는 애초에 repository 가 interface 여서 더 어색한 것 같기도 하네요. 어차피 spring jpa 플러그인을 모든 subproject 에 적용하기도 했고 application 에서도 tx 관리 + entity 관리를 한번에 하는게 좋아 보여서 jpa repository 를 그냥 application 에 넣는 것에 한표 던집니다. 보일러플레이트 코드도 좀 줄 것 같고요. |
저도 동의가 돼서, JPA로 전환할 때 이렇게 바꿔볼게용 |
8c1b119
to
45123a0
Compare
Checklist
Proposed Changes
,,
를 delimiter로 사용하던 리스트 컬럼을 json으로 바꾸도록 수정합니다.논의해야 할 것
이 작업의 범위가 아닌 것