문제

Is there a way one EntityManager can participate smoothely in multiple concurrent transactions?

Well, not that concurrent. Something like:

  1. Start tx 1
  2. Do stuff in tx 1
  3. Start tx 2
  4. Do stuff in tx 2
  5. Commit tx 2
  6. Join tx 1 back
  7. Do stuff in tx 1
  8. Commit tx 1

with steps followed one by one not overlapping.

도움이 되었습니까?

해결책

Separate transactions? No, it can not.

Attempting to call EntityTransaction.begin() on a currently active transaction (which is what you would have to do, diretly or indirectly) will result in IllegalStateException being thrown.

Unit of work / transaction scope concepts are explained in detail in the Hibernate EntityManager manual.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top