> What are your experiences and best practices? semantics of equals(Object other) should stay close to equate the fields that constitute persistent identity of a type.
// Two distinct contexts EntityManager em1 = ...; EntityManager em2 = ...; // One user-visible persistent identity Object pid = ...; // Access a persistent instance in two separate contexts X pc1 = em1.find(X.class, pid); X pc2 = em2.find(X.class, pid); // Access their persistent identity in distinct contexts Object id1 = em1.getObjectId(pc1); Object id2 = em2.getObjectId(pc2); // These assertions are true by design assertNotSame(pc1, pc2); // same persistent data gets realized as distinct objects in distinct context assertEquals(id1, id2); // their persistent identity equals by value // The user-written equals() *should* honor the following assertEquals(pc1, pc2); ----- Pinaki Poddar Chair, Apache OpenJPA Project -- View this message in context: http://openjpa.208410.n2.nabble.com/Best-practice-Overriding-equals-in-entities-tp6672154p6673341.html Sent from the OpenJPA Users mailing list archive at Nabble.com.