[关于JpaRepository
s save()
方法的一个方面,我正在尝试检查要保存的实体是新实体还是已经存在并且应该更新。
[我注意到Spring Data REST uses the isNew()
method类的isNew()
,但没有发现我只有在要创建或更新的实体的模型类的情况下,才可能获得PersistentEntity
对象。
如何从要存储或更新的实体中检索Spring Data的PersistentEntity
对象?
最简单的方法是只注入一个PersistentEntity
实例并从中获取Repositories
:
PersistentEntity