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 totrue.- Author:
- Collin Alpert
-
-
Field Summary
-
Fields inherited from class com.github.collinalpert.java2db.services.BaseService
tableName, type
-
-
Constructor Summary
Constructors Constructor Description BaseDeletableService()
-
Method Summary
Modifier and Type Method Description voiddelete(long id)Performs a soft delete on an entity instead of completely deleting it from the database.voiddelete(long... ids)Performs a soft delete on a variable amount of entities instead of completely deleting them from the database.voiddelete(com.github.collinalpert.lambda2sql.functions.SqlPredicate<T> predicate)Performs a soft delete based on a condition instead of completely deleting entities from the database.voiddelete(java.util.List<T> entities)Performs a soft delete on an list of entities instead of completely deleting them from the database.voiddelete(T instance)Performs a soft delete on an entity instead of completely deleting it from the database.voiddelete(T... entities)Performs a soft delete on an variable amount of entities instead of completely deleting them from the database.-
Methods inherited from class com.github.collinalpert.java2db.services.BaseService
any, any, count, count, create, create, create, createPagination, createPagination, createPagination, createPagination, createQuery, createSingleQuery, getAll, getAll, getAll, getAll, getAll, getById, getFirst, getMultiple, getSingle, hasDuplicates, truncateTable, update, update, update, update, update
-
-
-
-
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:
deletein classBaseService<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.SQLExceptionPerforms a soft delete on an entity instead of completely deleting it from the database.- Overrides:
deletein classBaseService<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:
deletein classBaseService<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:
deletein classBaseService<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.SQLExceptionPerforms a soft delete on a variable amount of entities instead of completely deleting them from the database.- Overrides:
deletein classBaseService<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:
deletein classBaseService<T extends BaseDeletableEntity>- Parameters:
predicate- The condition to soft-delete by.- Throws:
java.sql.SQLException- for example because of a foreign key constraint.
-
-