Class AbstractRepository<T extends AbstractEntity>

  • Type Parameters:
    T - the generic type
    All Implemented Interfaces:
    Serializable

    public abstract class AbstractRepository<T extends AbstractEntity>
    extends Object
    implements Serializable
    The Class defines basic CRUD operation on entities stored in database.
    Since:
    0.1.0
    Author:
    michalt
    See Also:
    Serialized Form
    • Constructor Detail

      • AbstractRepository

        public AbstractRepository​(Class<T> clazz,
                                  boolean useDefault)
        Instantiates a new abstract repository.
        Parameters:
        clazz - the clazz
        useDefault - the use default
      • AbstractRepository

        public AbstractRepository​(Class<T> clazz,
                                  DbrunkService databaseService)
        Instantiates a new abstract repository.
        Parameters:
        clazz - the clazz
        databaseService - the database service
    • Method Detail

      • setDbrunkService

        protected void setDbrunkService​(DbrunkService databaseService)
        Sets the dbrunk service.
        Parameters:
        databaseService - the new dbrunk service
      • getDbrunkService

        protected DbrunkService getDbrunkService()
        Gets the dbrunk service.
        Returns:
        the dbrunk service
      • save

        public T save​(T entity)
        Creates or updates entity.
        Parameters:
        entity - the entity
        Returns:
        the t
      • find

        public T find​(Long id)
        Finds entity by id.
        Parameters:
        id - the id
        Returns:
        the t
      • findAll

        public List<T> findAll()
        Finds all entities in table.
        Returns:
        the list
      • remove

        public void remove​(Long id)
        Removes the entity by id.
        Parameters:
        id - the id
      • remove

        public void remove​(T entity)
        Removes the entity.
        Parameters:
        entity - the entity
      • removeAll

        public void removeAll()
        Removes the all.