BaseCodeAndDescriptionServicepublic class BaseService<T extends BaseEntity> extends Object
Class that provides base functionality for all service classes. Every service class must extend this class.
| Constructor | Description |
|---|---|
BaseService(Class<T> clazz) |
Constructor for the base class of all services.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
create(T instance) |
Creates a Java entity on the database.
|
void |
delete(int id) |
Deletes a row by an id.
|
void |
delete(T instance) |
Deletes the corresponding row on the database.
|
List<T> |
getAll() |
|
T |
getById(int id) |
|
protected ResultSet |
getByPredicate(SqlPredicate<T> predicate,
DBConnection connection) |
|
List<T> |
getMultiple(SqlPredicate<T> predicate) |
|
T |
getSingle(SqlPredicate<T> predicate) |
|
boolean |
update(T instance) |
Applies updates to an entity on the database.
|
public boolean create(T instance)
instance - The instance to create on the database.True if the INSERT was successful, false if not.protected ResultSet getByPredicate(SqlPredicate<T> predicate, DBConnection connection)
predicate - The SqlPredicate for constraints on the SELECT query.connection - A connection to execute the query on.ResultSet by a predicate.public T getSingle(SqlPredicate<T> predicate)
predicate - The SqlPredicate to add constraints to a SELECT query.public List<T> getMultiple(SqlPredicate<T> predicate)
predicate - The SqlPredicate to add constraints to a SELECT query.public T getById(int id)
id - The id of the desired entity.public boolean update(T instance)
instance - The instance to update on the interface.True if the update is successful, false if not.public void delete(T instance)
instance - The instance to delete on the database.public void delete(int id)
id - The row with this id to delete.Copyright © 2018. All rights reserved.