Class AbstractStore<T>

java.lang.Object
io.dropwizard.hibernate.AbstractDAO<T>
org.ctan.site.stores.base.AbstractStore<T>
Type Parameters:
T - the type of the entity
Direct Known Subclasses:
AbstractIndexingStore, MessageStore, StopwordStore, TexArchiveNotesStore, UploadStore, UserStopwordStore, VoteStore

public abstract class AbstractStore<T> extends io.dropwizard.hibernate.AbstractDAO<T>
The class AbstractStore contains the abstract repository for CRUD operations on an entity.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AbstractStore(org.hibernate.SessionFactory sessionFactory)
    This is the constructor for AbstractStore.
  • Method Summary

    Modifier and Type
    Method
    Description
    getById(@NonNull Long id)
    The method getById provides means to retrieve the entity by its id.
    list(String term, int page, int pageSize, String orderBy, boolean asc)
    The method list provides means to extract a page of items.
    protected abstract jakarta.persistence.criteria.Root<T>
    listQuery(String term, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<T> query)
    The method listQuery provides means to construct a query for the list of entities for a search.
    protected abstract List<Map<String,Object>>
    map(List<T> list)
    The method map provides means to format a list for external use.
    boolean
    remove(@NonNull Long id)
    The method remove provides means to remove an entity by its id.
    void
    remove(List<T> list)
    The method remove provides means to remove a list of entities.
    boolean
    remove(T entity)
    The method remove provides means to remove an entity.
    save(T entity)
    The method save provides means to store an entity in the database.

    Methods inherited from class io.dropwizard.hibernate.AbstractDAO

    criteriaQuery, currentSession, get, getEntityClass, initialize, list, list, namedQuery, namedTypedQuery, persist, query, uniqueResult, uniqueResult

    Methods inherited from class java.lang.Object

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

    • AbstractStore

      public AbstractStore(org.hibernate.SessionFactory sessionFactory)
      This is the constructor for AbstractStore.
      Parameters:
      sessionFactory - the session factory
  • Method Details

    • getById

      public T getById(@NonNull @NonNull Long id)
      The method getById provides means to retrieve the entity by its id.
      Parameters:
      id - the id
      Returns:
      the entity or null if non is present
    • list

      public GeneralPage list(String term, int page, int pageSize, String orderBy, boolean asc)
      The method list provides means to extract a page of items.
      Parameters:
      term - the search term
      page - the current page
      pageSize - the page size
      orderBy - the order
      asc - the indicator for ascending
      Returns:
      the page
    • listQuery

      protected abstract jakarta.persistence.criteria.Root<T> listQuery(String term, jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.CriteriaQuery<T> query)
      The method listQuery provides means to construct a query for the list of entities for a search.
      Parameters:
      term - the search term
      cb - the criteria builder
      query - the query
      Returns:
      the root
    • map

      protected abstract List<Map<String,Object>> map(List<T> list)
      The method map provides means to format a list for external use.
      Parameters:
      list - the list of entries
      Returns:
      the formatted list
    • remove

      public void remove(List<T> list)
      The method remove provides means to remove a list of entities.
      Parameters:
      list - the list of entries
    • remove

      public boolean remove(@NonNull @NonNull Long id)
      The method remove provides means to remove an entity by its id.
      Parameters:
      id - the id
      Returns:
      true iff something has been removed
    • remove

      public boolean remove(T entity)
      The method remove provides means to remove an entity.
      Parameters:
      entity - the entity
      Returns:
      true iff something has been removed
    • save

      public T save(@NonNull T entity)
      The method save provides means to store an entity in the database.
      Parameters:
      entity - the entity
      Returns:
      the entity