What you assign one object to another, all you're doing is copying the reference to the object, not the contents of it. What you need to do is take your object B and manually copy the contents of object A into it.
If you do this often, you might consider implementing a clone()
method on the class that will create a new object of the same type, and copy all of it's contents into the new object.