Class BaseDeletableService<T extends BaseDeletableEntity>

  • Direct Known Subclasses:
    BaseCodeAndDescriptionDeletableService

    public class BaseDeletableService<T extends BaseDeletableEntity>
    extends BaseService<T>
    Describes a service class for an entity which contains an id and an isDeleted flag. Note that when deleting entities which have an isDeleted flag with this service, they will not actually be deleted from the database, but the flag will be set to true.
    Author:
    Collin Alpert
    • Method Summary

      Modifier and Type Method Description
      void delete​(long id)
      Performs a soft delete on an entity instead of completely deleting it from the database.
      void delete​(long... ids)
      Performs a soft delete on a variable amount of entities instead of completely deleting them from the database.
      void delete​(com.github.collinalpert.lambda2sql.functions.SqlPredicate<T> predicate)
      Performs a soft delete based on a condition instead of completely deleting entities from the database.
      void delete​(java.util.List<T> entities)
      Performs a soft delete on an list of entities instead of completely deleting them from the database.
      void delete​(T instance)
      Performs a soft delete on an entity instead of completely deleting it from the database.
      void delete​(T... entities)
      Performs a soft delete on an variable amount of entities instead of completely deleting them from the database.
      • Methods inherited from class java.lang.Object

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

      • BaseDeletableService

        public BaseDeletableService()
    • Method Detail

      • delete

        public void delete​(T instance)
                    throws java.sql.SQLException
        Performs a soft delete on an entity instead of completely deleting it from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        instance - The instance to soft-delete on the database.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.
      • delete

        public void delete​(long id)
                    throws java.sql.SQLException
        Performs a soft delete on an entity instead of completely deleting it from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        id - The row with this id to soft-delete.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.
      • delete

        public void delete​(java.util.List<T> entities)
                    throws java.sql.SQLException
        Performs a soft delete on an list of entities instead of completely deleting them from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        entities - The list of entities to soft-delete.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.
      • delete

        @SafeVarargs
        public final void delete​(T... entities)
                          throws java.sql.SQLException
        Performs a soft delete on an variable amount of entities instead of completely deleting them from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        entities - A variable amount of entities to soft-delete.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.
        See Also:
        BaseService.delete(List)
      • delete

        public void delete​(long... ids)
                    throws java.sql.SQLException
        Performs a soft delete on a variable amount of entities instead of completely deleting them from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        ids - The ids to soft-delete the rows by.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.
      • delete

        public void delete​(com.github.collinalpert.lambda2sql.functions.SqlPredicate<T> predicate)
                    throws java.sql.SQLException
        Performs a soft delete based on a condition instead of completely deleting entities from the database.
        Overrides:
        delete in class BaseService<T extends BaseDeletableEntity>
        Parameters:
        predicate - The condition to soft-delete by.
        Throws:
        java.sql.SQLException - for example because of a foreign key constraint.