Compare Java Objects Without Getters: reflectionEquals()
Learn to compare Java objects without getters or equals() using EqualsBuilder.reflectionEquals(), excluded fields, recursive mode and AssertJ.
Learn to compare Java objects without getters or equals() using EqualsBuilder.reflectionEquals(), excluded fields, recursive mode and AssertJ.
Learn how Java hashCode and equals work, the contract between them, why HashSet breaks when only equals() is overridden, plus records and mutable keys.
Hibernate returns one object per row inside a session but a new object in every other session. Implement equals() and hashCode() for entities with a generated id, a business key or a UUID, make them proxy-safe, and avoid Lombok @Data.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.