title: MongoDB type inference using _class
body: <p>I've been reading the <a href="http://static.springsource.org/spring-data/data-mongodb/docs/current/reference/html/mongo.core.html#mongo-template.type-mapping" rel="noreferrer"><code>MongoDB</code> documentation</a> and <code>Spring</code> adds a <strong>_class</strong> field by default to the stored data. Is there any way to use this information to have <strong>type inference</strong>?</p>
  
  <p>For example: There is a an abstract class Animal with three subclasses Dog, Cat, Bird. Say you have a class Zoo which contains a list of animals. In the database you store those Zoo Objects. Is there any function to get a <strong><code>List&lt;Animal&gt;</code></strong> back with Animals that can be upcasted?</p>
  
  <p>I'm using <code>Spring</code> so I prefer to have a solution that would work using the <code>spring-data-mongodb</code>. But an external mapping library would be fine too. I prefer not to write it myself as it seems basic mapping functionality.</p>