Search in sources :

Example 1 with User

use of org.springframework.data.mongodb.repository.User in project spring-data-mongodb by spring-projects.

the class CustomReactiveMongoRepositoryImpl method findByUsernameCustom.

@Override
public List<User> findByUsernameCustom(String username) {
    User user = new User();
    user.setUsername(username);
    return Collections.singletonList(user);
}
Also used : User(org.springframework.data.mongodb.repository.User)

Example 2 with User

use of org.springframework.data.mongodb.repository.User in project spring-data-mongodb by spring-projects.

the class SimpleMongoRepositoryTests method findAllByExampleShouldResolveDbRefCorrectly.

// DATAMONGO-1245
@Test
public void findAllByExampleShouldResolveDbRefCorrectly() {
    User user = new User();
    user.setId("c0nf1ux");
    user.setUsername("conflux");
    template.save(user);
    Person megan = new Person("megan", "tarash");
    megan.setCreator(user);
    repository.save(megan);
    Person sample = new Person();
    sample.setCreator(user);
    trimDomainType(sample, "id", "createdAt", "email");
    assertThat(repository.findAll(Example.of(sample))).hasSize(1).contains(megan);
}
Also used : User(org.springframework.data.mongodb.repository.User) Person(org.springframework.data.mongodb.repository.Person) Test(org.junit.Test)

Example 3 with User

use of org.springframework.data.mongodb.repository.User in project spring-data-mongodb by spring-projects.

the class CustomMongoRepositoryImpl method findByUsernameCustom.

/*
	 * (non-Javadoc)
	 * @see org.springframework.data.mongodb.repository.custom.CustomMongoRepository#findByFullName()
	 */
@Override
public List<User> findByUsernameCustom(String username) {
    User user = new User();
    user.setUsername(username);
    return Arrays.asList(user);
}
Also used : User(org.springframework.data.mongodb.repository.User)

Example 4 with User

use of org.springframework.data.mongodb.repository.User in project spring-data-mongodb by spring-projects.

the class QuerydslRepositorySupportTests method shouldAllowDbRefAgainstIdProperty.

// DATAMONGO-1394
@Test
public void shouldAllowDbRefAgainstIdProperty() {
    User bart = new User();
    bart.setUsername("bart@simpson.com");
    operations.save(bart);
    person.setCoworker(bart);
    operations.save(person);
    QPerson p = QPerson.person;
    SpringDataMongodbQuery<Person> queryUsingIdField = repoSupport.from(p).where(p.coworker.id.eq(bart.getId()));
    SpringDataMongodbQuery<Person> queryUsingRefObject = repoSupport.from(p).where(p.coworker.eq(bart));
    assertThat(queryUsingIdField.fetchOne(), equalTo(person));
    assertThat(queryUsingIdField.fetchOne(), equalTo(queryUsingRefObject.fetchOne()));
}
Also used : User(org.springframework.data.mongodb.repository.User) QPerson(org.springframework.data.mongodb.repository.QPerson) Person(org.springframework.data.mongodb.repository.Person) QPerson(org.springframework.data.mongodb.repository.QPerson) Test(org.junit.Test)

Aggregations

User (org.springframework.data.mongodb.repository.User)4 Test (org.junit.Test)2 Person (org.springframework.data.mongodb.repository.Person)2 QPerson (org.springframework.data.mongodb.repository.QPerson)1