What a “detached entity” means?
How is it possible to convert a managed entity to a detached entity during a transaction?
What a detached entity means? How is it possible to convert a managed entity
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
A detached entity is an entity whose state must not be reflected by the JPA provider.
In other words, if you change its state (i.e. through setters methods) these changes will not be saved to the underlying database, as the JPA provider doesn’t have to "observe" such entities.
If entity E1 is a managed entity you can make it detached invoking (very reasonable named) method
EntityManager#detach(E1). You can also useEntityManager#clear()which will clear whole PersistenceContext and effectively making all managed entities detached.