Have you had a chance to read this yet?
http://www.hibernate.org/109.html
I would recommend reading this 3 times and then once you think you understand it, read it again.
2 weeks after you get what you think is an implementation, read it again since what you did still probably doesn't work :)
If I seem cynical it is because we have been trying to define a eq/hc that will work for us in all scenarios with not a whole lot of success.
Other than that have you tried tracing your hashcode method to see when it is getting called and what the id is at that point?
I had a fun scenario earlier this week where I was using an ID from a parent many to one in a composite primary key and serializing my object. Upon deserialization the child object was being added into the parent's hashset before the id was available and chaos ensued.