Class ReservationRepositoryFactory
java.lang.Object
io.github.marcopaglio.booking.repository.factory.ReservationRepositoryFactory
A factory of repositories for Reservation entities.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptioncreateReservationRepository
(com.mongodb.client.MongoClient mongoClient, com.mongodb.client.ClientSession session, String databaseName) Creates a new repository for Reservation entities using a MongoDB client and session.createReservationRepository
(jakarta.persistence.EntityManager em) Creates a new repository for Reservation entities using PostgresSQL and a JPA provider.
-
Constructor Details
-
ReservationRepositoryFactory
public ReservationRepositoryFactory()Empty constructor.
-
-
Method Details
-
createReservationRepository
public ReservationMongoRepository createReservationRepository(com.mongodb.client.MongoClient mongoClient, com.mongodb.client.ClientSession session, String databaseName) throws IllegalArgumentException Creates a new repository for Reservation entities using a MongoDB client and session.- Parameters:
mongoClient
- the client using the MongoDB database.session
- the session in which database operations are performed.databaseName
- the name of the database in which the repository works.- Returns:
- a new
ReservationMongoRepository
for facing the MongoDB database. - Throws:
IllegalArgumentException
- if at leastmongoClient
orsession
is null.
-
createReservationRepository
public ReservationPostgresRepository createReservationRepository(jakarta.persistence.EntityManager em) Creates a new repository for Reservation entities using PostgresSQL and a JPA provider.- Parameters:
em
- the entity manager using PostgreSQL database.- Returns:
- a new
ReservationPostgresRepository
for facing the PostgreSQL database. - Throws:
IllegalArgumentException
- ifem
is null.
-