Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 entityManager,我想从具有实体名称的特定实体中删除数据,我该怎么做。我尝试使用 entitymanager.removeAll() 没有成功,有不同的方法来提供实体名称并删除其中的所有数据吗?
你可以使用这个:
entityManager.createQuery("delete from entity").executeUpdate();
用您的实体名称替换“实体”。它应该工作。但是,如果您对该实体有级联选项,则不会应用它们,您必须手动应用它们。
另一种解决方案是选择所有行并使用remove(entity)实体管理器的方法循环删除返回列表中包含的每个实体。
remove(entity)