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

public abstract class MongoRepository<T> extends Object
Facade of repository layer for using with MongoDB database.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected 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

    Constructors
    Modifier
    Constructor
    Description
    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.
  • Method Summary

    Modifier and Type
    Method
    Description
    final com.mongodb.client.MongoCollection<T>
    Retrieves the collection of entities of type T used by the repository layer.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • collection

      protected com.mongodb.client.MongoCollection<T> collection
      Collection of entities of type T used by the repository layer.
    • session

      protected com.mongodb.client.ClientSession session
      Session 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 - the MongoCollection of type T to set.
      session - the ClientSession to set.
  • Method Details

    • getCollection

      public final com.mongodb.client.MongoCollection<T> getCollection()
      Retrieves the collection of entities of type T used by the repository layer.
      Returns:
      the MongoCollection of type T used by the repository.