Example usage for org.springframework.data.redis.core PartialUpdate newPartialUpdate

List of usage examples for org.springframework.data.redis.core PartialUpdate newPartialUpdate

Introduction

In this page you can find the example usage for org.springframework.data.redis.core PartialUpdate newPartialUpdate.

Prototype

public static <S> PartialUpdate<S> newPartialUpdate(Object id, Class<S> targetType) 

Source Link

Document

Create new PartialUpdate for given id and type.

Usage

From source file:example.RedisRepositoryTests.java

@Test
public void partialUpdate() {

    Person egwene = new Person();
    egwene.firstname = "egwene";
    egwene.lastname = "al'vere";
    egwene.city = new City("new york");

    Person marin = new Person();
    marin.firstname = "marin";
    marin.lastname = "al'vere";

    repository.save(Arrays.asList(egwene, marin));

    PartialUpdate<Person> partialUpdate = PartialUpdate //
            .newPartialUpdate(egwene.getId(), Person.class)//
            .del("lastname")//
            .set("city.name", "Tear");

    kvTemplate.update(partialUpdate);/*from  w w w  .  j a  v a2s  .  c  om*/

    Person loaded = repository.findOne(egwene.getId());

    assertThat(loaded.getLastname(), is(nullValue()));
    assertThat(loaded.getCity().getName(), is(equalTo("Tear")));
}