OK, I RTFM'd, made some adjustments and still have this problem. Code to follow.
I create a persistable object.
I add it to a set.
I assert the set contains the object which passes.
I save the object.
I commit the transaction, close the session and reopen the session.
I retrieve the Permission from the db into a new reference.
I compare the hashcodes of these and call equals on both objets.
These tests pass so the retrieved object equals the original object in every way except they are separate instances.
I assert the original object is contained in the Set. This passes.
I assert the retrieved object is contained in the Set. This fails.
Code:
        Permission permission = new Permission( "test permission " + uniqueLongValue() ); 
        Set s = new HashSet();
        s.add( permission );
        assertTrue(s.contains( permission )); 
        session.save( permission );
        commitTransactionCloseAndReopenSession();
        
        Permission retrievedPermission = (Permission )session.get(Permission.class, permission.getId());
        assertEquals(permission.hashcode(), retrievedPermission.hashcode());
        
        assertEquals(permission, retrievedPermission);
        assertEquals(retrievedPermission, permission);
        
        assertFalse(permission == retrievedPermission);
        
        assertTrue(s.contains( permission )); 
        assertTrue(s.contains( retrievedPermission ));   
Pleaseandthankyou