Class JKMongoDataAccess

java.lang.Object
com.jk.data.vendors.mongo.JKMongoDataAccess
All Implemented Interfaces:
JKNoSqlDataAccess, JKObjectDataAccess

public class JKMongoDataAccess extends Object implements JKNoSqlDataAccess
The Class JKMongoDataAccess.
  • Constructor Details

    • JKMongoDataAccess

      public JKMongoDataAccess()
  • Method Details

    • getCollection

      protected <T> com.mongodb.client.MongoCollection<T> getCollection(Class<?> clas)
      Gets the collection.
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the collection
    • getDocumentName

      protected String getDocumentName(Class<?> clas)
      Gets the document name.
      Parameters:
      clas - the clas
      Returns:
      the document name
    • insert

      public <T> T insert(T obj)
      Insert.
      Specified by:
      insert in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      obj - the obj
      Returns:
      the t
    • getList

      public <T> List<T> getList(Class<T> clas)
      Gets the list.
      Specified by:
      getList in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the list
    • findByFieldName

      public <T> List<T> findByFieldName(Class<T> clas, String fieldName, Object value)
      Find by field name.
      Specified by:
      findByFieldName in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      fieldName - the field name
      value - the value
      Returns:
      the list
    • getList

      public <T> List<T> getList(Class<T> clas, Map<String,Object> filter)
      Gets the list.
      Specified by:
      getList in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      filter - the filter
      Returns:
      the list
    • find

      public <T> T find(Class<T> clas, Object id)
      Find.
      Specified by:
      find in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      id - the id
      Returns:
      the t
    • delete

      public <T> T delete(Class<T> clas, Object id)
      Delete.
      Specified by:
      delete in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      id - the id
      Returns:
      the t
    • delete

      public <T> T delete(T obj)
      Delete.
      Specified by:
      delete in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      obj - the obj
      Returns:
      the t
    • update

      public <T> T update(T obj)
      Update.
      Specified by:
      update in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      obj - the obj
      Returns:
      the t
    • update

      public <T> T update(Object id, T obj)
      Update.
      Type Parameters:
      T - the generic type
      Parameters:
      id - the id
      obj - the obj
      Returns:
      the t
    • findOneByFieldName

      public <T> T findOneByFieldName(Class<T> clas, String fieldName, Object fieldValue)
      Find one by field name.
      Specified by:
      findOneByFieldName in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      fieldName - the field name
      fieldValue - the field value
      Returns:
      the t
    • executeQuery

      public <T> List<T> executeQuery(Class<T> clas, String queryString, Object... paramters)
      Execute query.
      Specified by:
      executeQuery in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      queryString - the query string
      paramters - the paramters
      Returns:
      the list
    • insertOrUpdate

      public <T> T insertOrUpdate(T object)
      Insert or update.
      Specified by:
      insertOrUpdate in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      object - the object
      Returns:
      the t
    • setMaxResults

      public void setMaxResults(int maxResults)
      Sets the max results.
      Specified by:
      setMaxResults in interface JKObjectDataAccess
      Parameters:
      maxResults - the new max results
    • detach

      public <T> void detach(T model)
      Detach.
      Specified by:
      detach in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      model - the model
    • clone

      public <T> T clone(T model)
      Clone.
      Specified by:
      clone in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      model - the model
      Returns:
      the t
    • startTransaction

      public void startTransaction()
      Start transaction.
      Specified by:
      startTransaction in interface JKObjectDataAccess
    • closeTransaction

      public void closeTransaction(boolean commit)
      Close transaction.
      Specified by:
      closeTransaction in interface JKObjectDataAccess
      Parameters:
      commit - the commit
    • getListAndCache

      public <T> List<T> getListAndCache(Class<T> clas)
      Gets the list and cache.
      Specified by:
      getListAndCache in interface JKObjectDataAccess
      Type Parameters:
      T - the generic type
      Parameters:
      clas - the clas
      Returns:
      the list and cache