Skip to content

Use QueryDSL Path expressions to specify field constraints on repository queries [DATAMONGO-103] #1039

Closed as not planned
@spring-projects-issues

Description

@spring-projects-issues

Mark Pollack opened DATAMONGO-103 and commented

Instead of

public interface PersonRepository extends MongoRepository<Person, String>

  @Query(value="{ 'firstname' : ?0 }", fields="{'firstname' : 1, 'lastname' : 1")
  List<Person> findByThePersonsFirstname(String firstname);
}

if we had

public interface PersonRepository extends MongoRepository<Person, String>

  @Query(value="{ 'firstname' : ?0 }",
  List<Person> findByThePersonsFirstname(String firstname, Path<Person>... paths);
}

or more generally

public interface PersonRepository extends MongoRepository<Person, String>
 
  List<Person> findByFirstname(String firstname, Path<Person>... paths);
}

would like to invoke like this

List<Person> folks = repo.findByFirstname(String firstname, QPerson.firstName, QPerson.lastName);

Affects: 1.0 M2

1 votes, 1 watchers

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions