JPA: applicationManaged EntityManager for Java SE for programmatic transaction lifecycle management

I am having difficulty finding a good solution to support this feature, when the user interface can start and commit the transaction.

In my previous approaches to working with transactional applications, I group a unit of work into a service method into a backend and annotate it using spring @Transactional.


But imagine that I have several service methods like this, and before the frontend group service method calls within a transaction.

For example, I have a methodServiceA, methodServiceB, methodServiceC. The user interface might do something similar with any combinations, such as:

Combination 1:

  • starts a transaction
  • call methodServiceA + call methodServiceB
  • commits a transaction

Combination 2:

  • starts a transaction
  • call methodServiceB + call methodServiceC
  • commits a transaction

Combination 3:

  • starts a transaction
  • call methodServiceA + call methodServiceB + call methodServiceC
  • commits a transaction

Basically, the backend only provides a service method, and it corresponds to the user interface or other applications that use the backend to start / commit the transaction.


So this is basically the situation I am dealing with, and that is what I mean. Please share some other options or possibly improvements that I can make to support this feature. Im currently thinking about using a managed entitymanager application, since I don't think using @Transactional will work in this case.

Im , :

  • em
  • - em
  • em
  • , em
  • ,
  • em

, 1 :

  • ui entitymanager
  • entitymanager methodServiceA + ServiceB, , id

, !


/:

. , , , ( ui, , ).

, , .

, ui . ui .

+3
2

: , ( ), , Spring. .

0

- , .

- , , t . , .

0

Source: https://habr.com/ru/post/1794083/


All Articles