Package cz.tvrzna.dbrunk.repositories
Class AbstractRepository<T extends AbstractEntity>
- java.lang.Object
-
- cz.tvrzna.dbrunk.repositories.AbstractRepository<T>
-
- Type Parameters:
T- the generic type
- All Implemented Interfaces:
Serializable
public abstract class AbstractRepository<T extends AbstractEntity> extends Object implements Serializable
The Class defines basic CRUD operation on entities stored in database.- Since:
- 0.1.0
- Author:
- michalt
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description AbstractRepository(Class<T> clazz, boolean useDefault)Instantiates a new abstract repository.AbstractRepository(Class<T> clazz, DbrunkService databaseService)Instantiates a new abstract repository.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tfind(Long id)Finds entity byid.List<T>findAll()Finds all entities in table.protected DbrunkServicegetDbrunkService()Gets the dbrunk service.voidremove(Long id)Removes the entity byid.voidremove(T entity)Removes the entity.voidremoveAll()Removes the all.Tsave(T entity)Creates or updates entity.protected voidsetDbrunkService(DbrunkService databaseService)Sets the dbrunk service.
-
-
-
Constructor Detail
-
AbstractRepository
public AbstractRepository(Class<T> clazz, boolean useDefault)
Instantiates a new abstract repository.- Parameters:
clazz- the clazzuseDefault- the use default
-
AbstractRepository
public AbstractRepository(Class<T> clazz, DbrunkService databaseService)
Instantiates a new abstract repository.- Parameters:
clazz- the clazzdatabaseService- the database service
-
-
Method Detail
-
setDbrunkService
protected void setDbrunkService(DbrunkService databaseService)
Sets the dbrunk service.- Parameters:
databaseService- the new dbrunk service
-
getDbrunkService
protected DbrunkService getDbrunkService()
Gets the dbrunk service.- Returns:
- the dbrunk service
-
save
public T save(T entity)
Creates or updates entity.- Parameters:
entity- the entity- Returns:
- the t
-
remove
public void remove(Long id)
Removes the entity byid.- Parameters:
id- the id
-
remove
public void remove(T entity)
Removes the entity.- Parameters:
entity- the entity
-
removeAll
public void removeAll()
Removes the all.
-
-