Class MongoRepository<T>
java.lang.Object
io.github.marcopaglio.booking.repository.mongo.MongoRepository<T>
- Type Parameters:
T
- the entity type managed by the repository.
- Direct Known Subclasses:
ClientMongoRepository
,ReservationMongoRepository
Facade of repository layer for using with MongoDB database.
-
Field Summary
Modifier and TypeFieldDescriptionprotected com.mongodb.client.MongoCollection<T>
Collection of entities of type T used by the repository layer.protected com.mongodb.client.ClientSession
Session used to communicate with MongoDB database. -
Constructor Summary
ModifierConstructorDescriptionprotected
MongoRepository
(com.mongodb.client.MongoCollection<T> collection, com.mongodb.client.ClientSession session) Sets the collection of entities of type T and the session used by the repository layer. -
Method Summary
Modifier and TypeMethodDescriptionfinal com.mongodb.client.MongoCollection<T>
Retrieves the collection of entities of type T used by the repository layer.
-
Field Details
-
collection
Collection of entities of type T used by the repository layer. -
session
protected com.mongodb.client.ClientSession sessionSession used to communicate with MongoDB database.
-
-
Constructor Details
-
MongoRepository
protected MongoRepository(com.mongodb.client.MongoCollection<T> collection, com.mongodb.client.ClientSession session) Sets the collection of entities of type T and the session used by the repository layer.- Parameters:
collection
- theMongoCollection
of typeT
to set.session
- theClientSession
to set.
-
-
Method Details
-
getCollection
Retrieves the collection of entities of type T used by the repository layer.- Returns:
- the
MongoCollection
of typeT
used by the repository.
-