Example usage for org.springframework.data.mongodb.core.mapping PersonWithObjectId getId

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

Introduction

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

Prototype

public ObjectId getId() 

Source Link

Usage

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

@Test
public void testPersonPojo() throws Exception {

    LOGGER.info("about to create new personpojo");
    PersonWithObjectId p = new PersonWithObjectId(12345, "Person", "Pojo");
    LOGGER.info("about to insert");
    template.insert(p);/*from   w ww. j  av  a2 s .co m*/
    LOGGER.info("done inserting");
    assertNotNull(p.getId());

    List<PersonWithObjectId> result = template.find(new Query(Criteria.where("ssn").is(12345)),
            PersonWithObjectId.class);
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getSsn(), is(12345));
}