Skip to content

Repository - findBy<Field>IgnoreCase doesnt work [DATAMONGO-770] #1700

Closed
@spring-projects-issues

Description

@spring-projects-issues

regis opened DATAMONGO-770 and commented

I create a simple user document with an email field,

 
@Document(collection = "user")
public class UserDocument {

    @Id
    private ObjectId id;

    private String status;
    private String firstname;
    private String lastname;

    @Indexed(unique = true)
    private String email;

   all getter/ setter provided

}

 

Here my repository

 
public interface UserRepository extends CrudRepository<UserDocument, ObjectId>, QueryDslPredicateExecutor<UserDocument> {
    UserDocument findByEmailIgnoreCase(String email);

}

 

its working - i find a user document with

 
UserDocument foundUser = repository.findByEmailIgnoreCase("[email protected]");

 

its NOT working - i dont find a user document with

UserDocument foundUser = repository.findByEmailIgnoreCase("[email protected]");

 

I also try with the firstname it also doesnt work

Here my logs

 
DEBUG o.s.d.m.c.MongoTemplate - findOne using query: { "email" : "[email protected]"} in db.collection: portfolio_test.user

 

I m using spring-data-mongodb 1.3.1
mongodb 2.4.6
open jdk 7

I try to debug but it is in spring-data-common where it is handle the findBy stragegy lookup

PS: right now im using Query DSL to handle this

 
QUserDocument userDocument = new QUserDocument("userdocument");
return userRepository.findOne(userDocument.email.equalsIgnoreCase(email));

 


Affects: 1.3 GA, 1.3.1

Referenced from: commits e8a303b, fe41202

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions