I have created an user class like that :
The ICredentials interface :Code:public class User { /** * The list of roles for the user */ private List<String> roles; /** * The login information */ private ICredentials credentials; /*---- the constructors and getters/setters are omitted ---*/ }
One implementation :Code:public interface ICredentials { }
Now, I have created a repository to find a user from credentials :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 ---*/ }
Spring logs this (for both requests) : org.springframework.data.mongodb.core.MongoTemplat e [DEBUG] find using query: { "credentials" : { "login" : "test" , "password" : "test"}} fields: null for class: class xxx.User in collection: userCode:public interface MongoUserRepository extends MongoRepository<User, String> { List<User> findByCredentials(ICredentials credentials); List<User> findByCredentialsEquals(ICredentials credentials); }
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: { "credentials" : {"_class":"xxx.LoginPassword", "login" : "test" , "password" : "test"}}
Is something I doing wrong ? Am I missing something ?
Thanks
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)


Reply With Quote
, some sample repo on GitHub is sufficient. Also, please make it a minimal test case we can run through mvn clean test.
