Class DbrunkService


  • public class DbrunkService
    extends Object
    The Class DbrunkService.
    Author:
    michalt
    • Constructor Detail

      • DbrunkService

        public DbrunkService()
    • Method Detail

      • getInstance

        public static DbrunkService getInstance()
        Gets the single instance of DbrunkService.
        Returns:
        single instance of DbrunkService
      • save

        public <T extends AbstractEntity> T save​(Class<T> clazz,
                                                 T entity)
        Saves entity into Database.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
        entity - the entity
        Returns:
        the t
      • find

        public <T extends AbstractEntity> T find​(Class<T> clazz,
                                                 Long id)
        Finds entity by id.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
        id - the id
        Returns:
        the t
      • findAll

        public <T extends AbstractEntityList<T> findAll​(Class<T> clazz)
        Finds all entities by class.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
        Returns:
        the list
      • remove

        public <T extends AbstractEntity> void remove​(Class<T> clazz,
                                                      Long id)
        Removes the entity by id.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
        id - the id
      • remove

        public <T extends AbstractEntity> void remove​(Class<T> clazz,
                                                      T entity)
        Removes the entity by reference.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
        entity - the entity
      • removeAll

        public <T extends AbstractEntity> void removeAll​(Class<T> clazz)
        Removes all entities defined by class.
        Type Parameters:
        T - the generic type
        Parameters:
        clazz - the clazz
      • commit

        public void commit()
        Performs commit operation on database.
      • isAutocommit

        public boolean isAutocommit()
        Checks, if is autocommit.
        Returns:
        true, if is autocommit
      • setAutocommit

        public void setAutocommit​(boolean autocommit)
        Sets the autocommit.
        Parameters:
        autocommit - the new autocommit