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

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

Introduction

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

Prototype

public PersonWithDbRef(Integer ssn, String firstName, String lastName, GeoLocation home) 

Source Link

Usage

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

@Test
public void testDbRef() {
    double[] pos = new double[] { 37.0625, -95.677068 };
    GeoLocation geo = new GeoLocation(pos);
    template.insert(geo);//from w ww . j  a  v a 2  s .  co  m

    PersonWithDbRef p = new PersonWithDbRef(4321, "With", "DBRef", geo);
    template.insert(p);

    List<PersonWithDbRef> result = template.find(new Query(Criteria.where("ssn").is(4321)),
            PersonWithDbRef.class);
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getHome().getLocation(), is(pos));
}