Example usage for org.springframework.data.domain Persistable isNew

List of usage examples for org.springframework.data.domain Persistable isNew

Introduction

In this page you can find the example usage for org.springframework.data.domain Persistable isNew.

Prototype

boolean isNew();

Source Link

Document

Returns if the Persistable is new or was persisted already.

Usage

From source file:org.agatom.springatom.data.hades.repo.factory.NRepositoryImpl.java

@Override
public <S extends T> S save(S entity) {
    if (entity == null) {
        LOGGER.warn("save(...) called with null argument");
        return null;
    }//from   w  w  w.  ja  v  a2 s  .  c o  m
    final Persistable<?> persistable = (Persistable<?>) entity;
    final boolean isNew = persistable.isNew();
    this.publishBeforeCreateSaveEvent(entity, isNew);
    entity = super.save(entity);
    this.publishAfterCreateSaveEvent(entity, isNew);
    return entity;
}