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

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

Introduction

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

Prototype

public PersonWithLongDBRef(Integer ssn, String firstName, String lastName, PersonPojoLongId personPojoLongId) 

Source Link

Usage

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

@Test
public void testPersonWithLongDBRef() {
    PersonPojoLongId personPojoLongId = new PersonPojoLongId(12L, "PersonWithLongDBRef");
    template.insert(personPojoLongId);/*from  w w w  .  j  av  a2  s . com*/

    PersonWithLongDBRef personWithLongDBRef = new PersonWithLongDBRef(21, "PersonWith", "LongDBRef",
            personPojoLongId);
    template.insert(personWithLongDBRef);

    Query q = query(where("ssn").is(21));
    PersonWithLongDBRef p2 = template.findOne(q, PersonWithLongDBRef.class);
    assertNotNull(p2);
    assertNotNull(p2.getPersonPojoLongId());
    assertEquals(12L, p2.getPersonPojoLongId().getId());
}