This should be the case even if the EARs are deployed on different servers.
So, do all the 3 bean share the same persistence context? I've read that beans from other apps should be used as remote and not local beans.
1 of 1 people found this helpful
I do not believe so.
I suspect that any JPA entities passed as arguments between applications would need to be transferred between persistence contexts.
ie. detached by the sender and merged by the receiver
That is, unless they are not updated (read only), otherwise you will have concurrency problems.
So, if each app has its own persistence context how are the transactions managed? XA? by default - without me configuring anything?
Can someone clear this for me pls?
If you use the remote interface of the EJB (I suppose you use ejb3) this will handled by the ejb-client library.
The transaction is automaticaly propagated and use an XA approach even if you run the app with two different servers.
The problem is, if you use the same entities in both applications (which should not be very common) you might run into concurrency problems as the entities are loaded by different managers and if you update it in app1, call app2 update it here app1 is not aware about the update and think that the current entity is up-to-date.
If you have such use-case you need to re-read the entity or use a detach/attach as scoy said and ensure that you have an actual entity after returned from the other app.