title: Spring-data mongodb repository and inheritance
body: <p>I have created a class user class like that :</p>
  
  <pre><code>public class User {
      /**
       * The list of roles for the user
       */
      private List&lt;String&gt; roles;
      /**
       * The login information
       */
      private ICredentials credentials;
  
      /*---- the constructors and getters/setters are omitted ---*/
  }
  </code></pre>
  
  <p>The ICredentials interface :</p>
  
  <pre><code>public interface ICredentials {
  }
  </code></pre>
  
  <p>One implementation :</p>
  
  <pre><code>public class LoginPassword implements ICredentials {
      /**
       * The login of the user
       */
      protected String login;
  
      /**
       * The password of the user
       */
      protected String password;
  
      /*---- the constructors and getters/setters are omitted ---*/
  }
  </code></pre>
  
  <p>Now, I have created a repository to find a user from credentials :</p>
  
  <pre><code>public interface MongoUserRepository extends MongoRepository&lt;User, String&gt; {
      List&lt;User&gt; findByCredentials(ICredentials credentials);
      List&lt;User&gt; findByCredentialsEquals(ICredentials credentials);
  }
  </code></pre>
  
  <p>Spring logs this (for both requests) :
      org.springframework.data.mongodb.core.MongoTemplate [DEBUG] find using query: <code>{ "credentials" : { "login" : "test" , "password" : "test"}}</code> fields: null for class: class xxx.User in collection: user</p>
  
  <p>And it doesn't found anything... It seems that it doesn't found anything because the "_class" attribute is not written is the request. I think the good request should be:
  <code>{ "credentials" : {</code><strong><code>"_class":"xxx.LoginPassword"</code></strong><code>, "login" : "test" , "password" : "test"}}</code></p>
  
  <p>Is something I doing wrong ? Am I missing something ?</p>
  
  <p>Thanks</p>
  
  <p>I use spring mvc 3.2.0, spring-data-commons-core 1.4.0, spring-data-mongodb 1.1.1 and mongo-java-driver 2.10.1 (I have updated all libraries to the latest version to be sure it wasn't a bug already fixed but no success)</p>