I'm talking about JPA in JavaEE. In a book that i read talk about:
EntityManager em;
em.find(Employee.class, id);
"This is all the information needed by the entity manager to find the instance in the database, and when the call completes, the employee that gets returned will be a managed entity, meaning that it will exist in the current persistence context associated with the entity manager - pro-ejb3-jpa".
But i don't know when an entity stop to be managed and i have to merge()
to be managed again if i want to update, delete...
By default, the persistence context is bound to the transaction. So the context is closed when the transaction is committed or rolled back. And once its closed, your entity, which was managed by the persistence context, becomes unmanaged.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With