Tricky object serialization
<p>What is the safest way to serialize any kind of Java Object such that when:</p>

<pre><code>DBObject obj = getFromDB;
Object id = obj.get(ID_KEY);
String s1 = safeSerialize(id); 
</code></pre>

<p>The <code>obj.get(ID_KEY)</code> method returns an object that serves as an "id", it could be a ObjectId, String, Long, Integer, or anyt kind of Object. </p>

<p>Then do the same thing:</p>

<pre><code>DBObject obj = getFromDB;
Object id = obj.get(ID_KEY);
String s2 = safeSerialize(id); 
</code></pre>

<p>I need to make sure the <code>s1</code> is still equals to <code>s2</code>. I mean, for example <code>obj.get()</code> method might return new instance of say, <code>new Integer(100)</code> for a given <code>ID_KEY</code>, still having a "serialized" version. </p>
