开发者

Spring Data (mongoDB), findBy proxied method on repository doesn't work with null values

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 destin开发者_C百科ationMail 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜