package org.springframework.data.domain;
import org.springframework.lang.Nullable;
/**
* Simple interface for entities.
*
* @param <ID> the type of the identifier
* @author Oliver Gierke
* @author Christoph Strobl
*/
public interface Persistable<ID> {
/**
* Returns the id of the entity.
*
* @return the id. Can be {@literal null}.
*/
@Nullable
ID getId();
/**
* Returns if the {@code Persistable} is new or was persisted already.
*
* @return if {@literal true} the object is new.
*/
boolean isNew();
}
实现
Persistable接口
override 这个isNew方法。如果是new,就生成insert语句,否则生成update。