[英]Delete detached entity spring jpa Repository interface
I was reading that deleting detached entity will cause IllegalArgumentExcetpion, the entity should be managed to be removed. 我在读,删除分离的实体将导致IllegalArgumentExcetpion,应管理该实体的删除。 However , I'm using spring JPA repository interface and the delete is working on a detached entity , I have created new entity with the ID I want to delete and I got no exception.
但是,我使用的是Spring JPA存储库接口,删除操作正在一个分离的实体上,我已经创建了一个具有要删除ID的新实体,我也没有例外。 is there any document says we can delete detached entity in spring jpa ?
是否有任何文件说我们可以在spring jpa中删除分离的实体? I couldn't find official document.
我找不到正式文件。
在可以使用repository.delete(entity)之前,应调用repository.find(entityID)来防止“分离的实体异常”。
Every entity has id and you can delete deatached entity by id like 每个实体都有ID,您可以按ID删除已拆离的实体,例如
@Modifying @Query("delete from OwnEntity e where e.id = :id")
Long deleteById(@Param("id") Long id);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.