Package cz.tvrzna.dbrunk
Class DbrunkService
- java.lang.Object
-
- cz.tvrzna.dbrunk.DbrunkService
-
public class DbrunkService extends Object
The Class DbrunkService.- Author:
- michalt
-
-
Constructor Summary
Constructors Constructor Description DbrunkService()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcommit()Performs commit operation on database.<T extends AbstractEntity>
Tfind(Class<T> clazz, Long id)Finds entity byid.<T extends AbstractEntity>
List<T>findAll(Class<T> clazz)Finds all entities by class.static DbrunkServicegetInstance()Gets the single instance of DbrunkService.voidinit(DbrunkType dbType, String filePath)Inits the dbrunk service.booleanisAutocommit()Checks, if is autocommit.<T extends AbstractEntity>
voidremove(Class<T> clazz, Long id)Removes the entity byid.<T extends AbstractEntity>
voidremove(Class<T> clazz, T entity)Removes the entity by reference.<T extends AbstractEntity>
voidremoveAll(Class<T> clazz)Removes all entities defined by class.<T extends AbstractEntity>
Tsave(Class<T> clazz, T entity)Saves entity into Database.voidsetAutocommit(boolean autocommit)Sets the autocommit.
-
-
-
Method Detail
-
getInstance
public static DbrunkService getInstance()
Gets the single instance of DbrunkService.- Returns:
- single instance of DbrunkService
-
init
public void init(DbrunkType dbType, String filePath) throws DbrunkInitException
Inits the dbrunk service.- Parameters:
dbType- the db typefilePath- the file path- Throws:
DbrunkInitException- the dbrunk init exception
-
save
public <T extends AbstractEntity> T save(Class<T> clazz, T entity)
Saves entity into Database.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazzentity- the entity- Returns:
- the t
-
find
public <T extends AbstractEntity> T find(Class<T> clazz, Long id)
Finds entity byid.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazzid- the id- Returns:
- the t
-
findAll
public <T extends AbstractEntity> List<T> findAll(Class<T> clazz)
Finds all entities by class.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazz- Returns:
- the list
-
remove
public <T extends AbstractEntity> void remove(Class<T> clazz, Long id)
Removes the entity byid.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazzid- the id
-
remove
public <T extends AbstractEntity> void remove(Class<T> clazz, T entity)
Removes the entity by reference.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazzentity- the entity
-
removeAll
public <T extends AbstractEntity> void removeAll(Class<T> clazz)
Removes all entities defined by class.- Type Parameters:
T- the generic type- Parameters:
clazz- the clazz
-
commit
public void commit()
Performs commit operation on database.
-
isAutocommit
public boolean isAutocommit()
Checks, if is autocommit.- Returns:
- true, if is autocommit
-
setAutocommit
public void setAutocommit(boolean autocommit)
Sets the autocommit.- Parameters:
autocommit- the new autocommit
-
-