我使用Hibernate作为JPA提供者,并在函数中创建不同实体的实例。一旦我为一个实体调用了clear(),我就无法对其他实体执行persist()操作。我的代码非常复杂,为了释放一些内存,我不得不为一种类型的实体(而不是其他类型的实体)调用flush()和clear()。entity2 = new EntityType2(
updatable = false)//other fields and their getters and setters
当我调用entityManager.persist(Employee emp)来持久化时,我得到了以下错误
javax.persistence.PersistenceException: org.hibernate.PersistentObjectException:传递给持久化的分离实体: com