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

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

Introduction

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

Prototype

public ObjectId getId() 

Source Link

Usage

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

@Test
public void testPersonMapProperty() {
    PersonMapProperty p = new PersonMapProperty(1234567, "Map", "PropertyPath");
    Map<String, AccountPojo> accounts = new HashMap<String, AccountPojo>();

    AccountPojo checking = new AccountPojo("checking", 1000.0f);
    AccountPojo savings = new AccountPojo("savings", 10000.0f);

    accounts.put("checking", checking);
    accounts.put("savings", savings);
    p.setAccounts(accounts);/*from  w  w  w . j av  a2  s  .c  om*/

    template.insert(p);
    assertNotNull(p.getId());

    List<PersonMapProperty> result = template.find(new Query(Criteria.where("ssn").is(1234567)),
            PersonMapProperty.class);
    assertThat(result.size(), is(1));
    assertThat(result.get(0).getAccounts().size(), is(2));
    assertThat(result.get(0).getAccounts().get("checking").getBalance(), is(1000.0f));
}