Spring Data (mongoDB),存储库上的 findBy 代理方法不适用于空值
我在 MongoRepository 扩展程序类中有一个代理方法,如下所示:
public interface InvitationRepository extends MongoRepository<Foo, String>
{
public Foo findByUserIdAndDestinationMail( String userId, String destinationMail );
}
当我尝试通过调用:
Foo foo = invitationRepository.findByUserIdAndDestinationMail( userId, null );
MappingMongoConverter
在数据库中查找没有任何 destinationMail
的 Foo
实例时> 抛出一个NullPointerException
。
我可以使用任何代理方法找到具有空值的实例吗?
如果我需要在自定义实现中创建方法,如何使用 mongoTemplate 来完成此操作?有这样的事吗?
mongoTemplate.findOne( new Query(
Criteria.where( "userId" ).is( userId ).and( "destinationMail" ).is(... )),
entityClass );
非常感谢。
I have a proxied method in a MongoRepository extender class like this:
public interface InvitationRepository extends MongoRepository<Foo, String>
{
public Foo findByUserIdAndDestinationMail( String userId, String destinationMail );
}
When I try to find a Foo
instance in DB without any destinationMail
by calling:
Foo foo = invitationRepository.findByUserIdAndDestinationMail( userId, null );
MappingMongoConverter
throws a NullPointerException
.
¿Can I find instances with null values with any proxied method?
If I need to create the method in a custom implementation ¿how can I do this with mongoTemplate
? ¿Is there somthing like this?
mongoTemplate.findOne( new Query(
Criteria.where( "userId" ).is( userId ).and( "destinationMail" ).is(... )),
entityClass );
Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
目前的1.0.1.RELEASE版本中似乎没有出现这个问题。因此,如果您遇到此问题,请升级到此版本。
The problem doesn't seem to appear in the current 1.0.1.RELEASE version. Thus if you face this issue, please upgrade to this version.