Class SqliteRepository<T>
- java.lang.Object
-
- com.droidlogix.sqlite.datahandler.SqliteRepository<T>
-
- All Implemented Interfaces:
ISqliteRepository<T>
public class SqliteRepository<T> extends Object implements ISqliteRepository<T>
Created by John Pili on 11/02/17.
-
-
Constructor Summary
Constructors Constructor Description SqliteRepository(SqliteConfig sqliteConfig)SqliteRepository(String dbLocation, String dbUsername, String dbPassword)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidalterTable(String sql)Method that handles alter tablevoidcreateTable(String sql)Method that handles create tableintdelete(String sql, Map<Integer,Object> parameters)Delete rows in SQLite and return the number of affected rowsvoiddropTable(String sql)Method that handles drop tableConnectiongetConnection()This method initialize the SQLite connection and driver checkList<T>getList(String sql, ISqliteObjectAssembler sqliteObjectAssembler)Query a list items using sql.List<T>getList(String sql, Map<Integer,Object> parameters, ISqliteObjectAssembler sqliteObjectAssembler)Query a list items using sql and map of parameters.TgetSingle(String sql, ISqliteObjectAssembler sqliteObjectAssembler)Query a single item using sql.TgetSingle(String sql, Map<Integer,Object> parameters, ISqliteObjectAssembler sqliteObjectAssembler)Query a single item using sql and map of parameters.intinsert(String sql, Map<Integer,Object> parameters)Insert into SQLite and return the generated primary ID.intupdate(String sql, Map<Integer,Object> parameters)Update rows in SQLite and return the number of affected rows
-
-
-
Constructor Detail
-
SqliteRepository
public SqliteRepository(SqliteConfig sqliteConfig)
-
-
Method Detail
-
getConnection
public Connection getConnection() throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryThis method initialize the SQLite connection and driver check- Specified by:
getConnectionin interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
insert
public int insert(String sql, Map<Integer,Object> parameters) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryInsert into SQLite and return the generated primary ID. Method will return -1 if an error occurs during execution- Specified by:
insertin interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
update
public int update(String sql, Map<Integer,Object> parameters) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryUpdate rows in SQLite and return the number of affected rows- Specified by:
updatein interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
delete
public int delete(String sql, Map<Integer,Object> parameters) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryDelete rows in SQLite and return the number of affected rows- Specified by:
deletein interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getSingle
public T getSingle(String sql, ISqliteObjectAssembler sqliteObjectAssembler) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryQuery a single item using sql. Convert resultset to POJO via dependency injection- Specified by:
getSinglein interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getSingle
public T getSingle(String sql, Map<Integer,Object> parameters, ISqliteObjectAssembler sqliteObjectAssembler) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryQuery a single item using sql and map of parameters. Convert resultset to POJO via dependency injection- Specified by:
getSinglein interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getList
public List<T> getList(String sql, ISqliteObjectAssembler sqliteObjectAssembler) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryQuery a list items using sql. Convert resultset to POJO via dependency injection- Specified by:
getListin interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getList
public List<T> getList(String sql, Map<Integer,Object> parameters, ISqliteObjectAssembler sqliteObjectAssembler) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryQuery a list items using sql and map of parameters. Convert resultset to POJO via dependency injection- Specified by:
getListin interfaceISqliteRepository<T>- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
createTable
public void createTable(String sql) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryMethod that handles create table- Specified by:
createTablein interfaceISqliteRepository<T>- Throws:
SQLExceptionSqliteDriverNotFoundException
-
alterTable
public void alterTable(String sql) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryMethod that handles alter table- Specified by:
alterTablein interfaceISqliteRepository<T>- Throws:
SQLExceptionSqliteDriverNotFoundException
-
dropTable
public void dropTable(String sql) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryMethod that handles drop table- Specified by:
dropTablein interfaceISqliteRepository<T>- Throws:
SQLExceptionSqliteDriverNotFoundException
-
-