There is a method called contains() that we can invoke on an Entity to check if that entity is available in the PersistenceContext. Likewise is there any way to attach an entity to a PersistenceContext apart from operating it using the entity operations like find() and getReference()?
The merge method is used (also) to attach an entity to context.
I think the answer to your question is no, there is nothing like attach method - there are a lot of tricks bue each one has pros and contras.
Regards
Mihai
This message was edited 1 time. Last update was at by Mihai Radulescu
Dont forget the createQuery():Query from the EntityManager. If is trigger isn a transaction then the entities resulted are attached to the corresponding persistnce context.
Regards,
Mihai
This message was edited 1 time. Last update was at by Mihai Radulescu