It sounds like you are comparing references and not data.
EDIT:
From the API doc for Object:
"The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true). "
e.g. If 'X' or it's parent classes do not override equals then when you call equals then it will be comparing the references, which if they are the same object will always be the equal.
By the sounds of it you need to override the equals method in the class 'X', but then again, what you say seems to indicate that they are the same reference anyhow?