|Re: Lazy load with detached entities [message #648586 is a reply to message #648319]
||Thu, 13 January 2011 10:20
| James Sutherland
Registered: July 2009
Location: Ottawa, Canada
detach() is not a very safe operation, so I would not recommend using it.|
Are both EJB's in the same transaction? If they are in different transactions, then everything will become detached and any changes will be ignored.
If they are in the same transaction, then would you not want to persist any changes?
If you were using a non-managed EntityManager you could just create a non-transactional EntityManager for your query, so its objects would never be committed. If you are using JTA and a EJB managed EntityManager this would be difficult.
You could also use copy() on the EclipseLink JpaEntityManager to detach the object to the desired depth.
Perhaps provide both a local and remote interface, and in the EJB's that want detached Entities use the remote one. OR fix your code that is incorrectly changing the Entities.
James : Wiki : Book : Blog : Twitter
Powered by FUDForum
. Page generated in 0.02179 seconds