Class TransactionPostgresManager
java.lang.Object
io.github.marcopaglio.booking.transaction.manager.TransactionManager
io.github.marcopaglio.booking.transaction.manager.postgres.TransactionPostgresManager
An implementation of
TransactionManager
for managing code executed
on PostgreSQL within transactions.-
Field Summary
Fields inherited from class io.github.marcopaglio.booking.transaction.manager.TransactionManager
clientRepositoryFactory, LOGGER, reservationRepositoryFactory, transactionHandlerFactory
-
Constructor Summary
ConstructorDescriptionTransactionPostgresManager
(jakarta.persistence.EntityManagerFactory emf, TransactionHandlerFactory transactionHandlerFactory, ClientRepositoryFactory clientRepositoryFactory, ReservationRepositoryFactory reservationRepositoryFactory) Constructs a manager for applying code that uses entity repositories using PostgreSQL transactions. -
Method Summary
Modifier and TypeMethodDescription<R> R
Prepares to execution of code that involves bothClientRepository
's andReservationRepository
's methods on PostgreSQL in a single transaction.<R> R
doInTransaction
(ClientTransactionCode<R> code) Prepares to execution of code that involves theClientRepository
's method(s) on PostgreSQL in a single transaction.<R> R
Prepares to execution of code that involves theReservationRepository
's method(s) on PostgreSQL in a single transaction.Methods inherited from class io.github.marcopaglio.booking.transaction.manager.TransactionManager
executeInTransaction, executeInTransaction, executeInTransaction, transactionFailureMsg
-
Constructor Details
-
TransactionPostgresManager
public TransactionPostgresManager(jakarta.persistence.EntityManagerFactory emf, TransactionHandlerFactory transactionHandlerFactory, ClientRepositoryFactory clientRepositoryFactory, ReservationRepositoryFactory reservationRepositoryFactory) Constructs a manager for applying code that uses entity repositories using PostgreSQL transactions.- Parameters:
emf
- the entity manager factory used to interact with the persistence provider.transactionHandlerFactory
- the factory to createEntityManager
instances.clientRepositoryFactory
- the factory to createClientPostgresRepository
instances.reservationRepositoryFactory
- the factory to createReservationPostgresRepository
instances.
-
-
Method Details
-
doInTransaction
Prepares to execution of code that involves theClientRepository
's method(s) on PostgreSQL in a single transaction.- Specified by:
doInTransaction
in classTransactionManager
- Type Parameters:
R
- the returned type of executed code.- Parameters:
code
- the code to execute.- Returns:
- something depending on execution code.
- Throws:
TransactionException
- if the execution or the commitment of the transaction fails.
-
doInTransaction
Prepares to execution of code that involves theReservationRepository
's method(s) on PostgreSQL in a single transaction.- Specified by:
doInTransaction
in classTransactionManager
- Type Parameters:
R
- the returned type of executed code.- Parameters:
code
- the code to execute.- Returns:
- something depending on execution code.
- Throws:
TransactionException
- if the execution or the commitment of the transaction fails.
-
doInTransaction
Prepares to execution of code that involves bothClientRepository
's andReservationRepository
's methods on PostgreSQL in a single transaction.- Specified by:
doInTransaction
in classTransactionManager
- Type Parameters:
R
- the returned type of executed code.- Parameters:
code
- the code to execute.- Returns:
- something depending on execution code.
- Throws:
TransactionException
- if the execution or the commitment of the transaction fails.
-