Class BaseDeletableService<T extends BaseDeletableEntity>

java.lang.Object
com.github.collinalpert.java2db.services.BaseService<T>
com.github.collinalpert.java2db.services.BaseDeletableService<T>
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
  • Constructor Details

  • Method Details

    • 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.