IdentityHashKey { public IdentityHashKey(final Object reference) { this.reference = reference; } IdentityHashKey(final Object reference); Object getReference(); @Override int hashCode(); @Override boolean equals(final Object obj);  }
@Test public void testIdentityHashKey() { final Set<IdentityHashKey> hashSet = new HashSet<IdentityHashKey>(); final PersistenceObject persistenceObject = new PersistenceObject(); final IdentityHashKey hashKey = new IdentityHashKey(persistenceObject); final PersistenceObject persistenceObject2 = new PersistenceObject(); final IdentityHashKey hashKey2 = new IdentityHashKey(persistenceObject2); hashSet.add(hashKey); Assert.assertTrue(hashSet.contains(hashKey)); persistenceObject.setId(Long.valueOf(1)); Assert.assertTrue(hashSet.contains(hashKey)); Assert.assertFalse(hashSet.contains(hashKey2)); persistenceObject2.setId(Long.valueOf(1)); Assert.assertFalse(hashSet.contains(hashKey2)); hashSet.add(hashKey2); Assert.assertTrue(hashSet.contains(hashKey)); Assert.assertTrue(hashSet.contains(hashKey2)); Assert.assertEquals(2, hashSet.size()); }