Why need detached entities in JPA?

前端 未结 6 602
礼貌的吻别
礼貌的吻别 2021-01-31 09:28

There are always so many questions related to issues with detached entities!

First, they often cause LazyInitializationException in Hibernate. Yes, there ar

6条回答
  •  无人共我
    2021-01-31 09:36

    It could be that an entity is seen as detached because it has the same ID as an entity in the persistence store. Imagine you got the entity from outside of the application. It could be that this entity is seen as detached when trying to persist it. There for you have to attach it again with, indeed, the merge.

    I can't really imagine other situations and I'm curious for the other answers.

提交回复
热议问题