On 16 Feb 2004 16:02, hengels wrote: >what about using the primary key and fall back to object identity if a >pk is not assigned? This breaks collections because it changes the object's hashcode once you save it. So you would get: UserManager u = session.load(UserManager.class, id); User newUser = new User("newUsername1"); u.getUserSet().add(newUser); // adds a new Entity with id = null or id = 0 session.save(newUser); session.flush(); // The id is now assigned to the newUser object if (!u.getUserSet().contains(newUser)) System.err.print("OOPS!"); This *will* print "OOPS!" because newUser's hashcode changed when you saved it, so the userSet can no longer find it. See this forum thread http://forum.hibernate.org/viewtopic.php?t=928172 for an exhaustive discussion of this problem.