我创建了一个类用户类这样的:弹簧数据MongoDB的仓库和继承
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 ---*/
}
的ICredentials接口:
public interface ICredentials {
}
一个实现:
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 ---*/
}
现在,我创建了一个信息库,以找到凭据的用户:
public interface MongoUserRepository extends MongoRepository<User, String> {
List<User> findByCredentials(ICredentials credentials);
List<User> findByCredentialsEquals(ICredentials credentials);
}
春季将这一情况记录(对于两个请求): org.springframework.data.mongodb.core.MongoTemplate [DEBUG]发现使用查询:{ "credentials" : { "login" : "test" , "password" : "test"}}
字段:空类:在集合类xxx.User:用户
而且它并没有发现什么...看来,它并没有发现任何东西,因为“_class”属性不写是请求。我认为好的要求应该是: { "credentials" : {
"_class":"xxx.LoginPassword"
, "login" : "test" , "password" : "test"}}
是我做错了吗?我错过了什么吗?
感谢
我使用Spring MVC的3.2.0,弹簧数据公共核心1.4.0,弹簧数据的MongoDB 1.1.1和蒙戈的Java驱动程序2.10.1(我已经全部更新库到最新版本,以确保它不是