Example usage for org.springframework.data.repository.core EntityInformation isNew

List of usage examples for org.springframework.data.repository.core EntityInformation isNew

Introduction

In this page you can find the example usage for org.springframework.data.repository.core EntityInformation isNew.

Prototype

boolean isNew(T entity);

Source Link

Document

Returns whether the given entity is considered to be new.

Usage

From source file:example.springdata.jpa.compositions.FlushOnSaveRepositoryImpl.java

/**
 * @param entity/*w w w .  j  ava2s .co m*/
 */
private <S extends T> void doSave(S entity) {

    EntityInformation<Object, S> entityInformation = getEntityInformation(entity);

    if (entityInformation.isNew(entity)) {
        entityManager.persist(entity);
    } else {
        entityManager.merge(entity);
    }
}