Why need detached entities in JPA?

前端 未结 6 586
礼貌的吻别
礼貌的吻别 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:41

    Detached entities (eagerly fetched) could work as DTOs in some cases. Probably not something that should be done in an enterprise application, but e.g. a java se based network game, where both the server and client come from same codebase, the player state could be reprented as entity and be transfered to/from server and persisted there.

    Not sure that it would be a better choise than proper DTO, but it could be technically done.

提交回复
热议问题