且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

javax.persistence.Entitymanager:remove()方法

更新时间:2023-09-20 22:34:10

删除JPA实体的ObjectDB手册中引用对象


为了从数据库中删除对象,必须首先检索
(无论是以及然后在活动事务中,可以使用remove方法删除

In order to delete an object from the database it has to first be retrieved (no matter which way) and then in an active transaction, it can be deleted using the remove method.

如果参数不是$,则抛出IllegalArgumentException b $ ba实体类的实例或者它是一个分离的实体。

An IllegalArgumentException is thrown by remove if the argument is not a an instance of an entity class or if it is a detached entity.

使用创建对象时新的运算符,它成为一个分离的实体,如果要删除它,则需要保留它。

When creating object with new operator, it becomes a detached entity, you need to persist it if you want to remove it.

检索实体时,您正在检索持久性实体。

When retrieving entity, you are retrieving persistent entity.