So I was working on Project Foundry stuff today and spent an hour or two trying to figure out why an object did not contain the data that I expected it to have. The query was executing correctly, returning the correct results and even populating the object correctly. Somewhere along the line, though, the data was getting lost. I finally realized that it was because of Java’s all-pointer approach. I added this user object to a response object and then populated it with some other data. Since adding the user object to the response didn’t actually clone the object but just sent along a memory address, successive changes to the user object caused a change in all “copies” of the object. I changed the user class so that it implements the Cloneable interface and that solved my problem.
Anyway … it’s another late night and I’m not sure how much sense I’m making, so I’m going to shower and go to bed.