Should @Transient property be used in equals/hashCode/toString?
问题 I have JPA entities where some properties are annotated with @Transient . Should I use these properties in equals/hashCode/toString methods? My first thought is NO but I don't know why. Tips? Ideas? Explanations? 回答1: The case of toString() is different, you can do whatever you want with toString() so I will only cover equals() (and hashCode() ). First, the rule: if you want to store an object in a List , Map or a Set then it is a requirement that equals and hashCode are implemented so they