How to find out whether an entity is detached in JPA / Hibernate?

后端 未结 2 1402
灰色年华
灰色年华 2021-01-31 14:34

Is there a way to query the JPA EntityManager whether a given entity is detached? This SO post is discussing a similar issue but does not indicate a way to quer

2条回答
  •  失恋的感觉
    2021-01-31 15:08

    To check if the given entity is managed by the current PersistenceContext you can use the EntityManager#contains(Object entity).

提交回复
热议问题