Example usage for org.springframework.data.mongodb.core.mapping PersonCustomCollection2 PersonCustomCollection2

List of usage examples for org.springframework.data.mongodb.core.mapping PersonCustomCollection2 PersonCustomCollection2

Introduction

In this page you can find the example usage for org.springframework.data.mongodb.core.mapping PersonCustomCollection2 PersonCustomCollection2.

Prototype

public PersonCustomCollection2(Integer ssn, String firstName, String lastName) 

Source Link

Usage

From source file:org.springframework.data.mongodb.core.mapping.MappingTests.java

@Test
public void testCustomCollectionInList() {
    List<BasePerson> persons = new ArrayList<BasePerson>();
    persons.add(new PersonCustomCollection1(55555, "Person", "One"));
    persons.add(new PersonCustomCollection2(66666, "Person", "Two"));
    template.insertAll(persons);/*from w w w.java  2s  .  co  m*/

    List<PersonCustomCollection1> p1Results = template.find(new Query(Criteria.where("ssn").is(55555)),
            PersonCustomCollection1.class, "person1");
    List<PersonCustomCollection2> p2Results = template.find(new Query(Criteria.where("ssn").is(66666)),
            PersonCustomCollection2.class, "person2");
    assertThat(p1Results.size(), is(1));
    assertThat(p2Results.size(), is(1));
}