Class SqliteRepository
- java.lang.Object
-
- com.droidlogix.sqlite.datahandler.SqliteRepository
-
- All Implemented Interfaces:
ISqliteRepository
public class SqliteRepository extends Object implements ISqliteRepository
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 checkConnectiongetConnection(boolean pragmaFk)This method initialize the SQLite connection and driver check<T> List<T>getList(String sql, ISqliteObjectAssembler sqliteObjectAssembler)Query a list items using sql.<T> List<T>getList(String sql, Map<Integer,Object> parameters, ISqliteObjectAssembler sqliteObjectAssembler)Query a list items using sql and map of parameters.<T> TgetSingle(String sql, ISqliteObjectAssembler sqliteObjectAssembler)Query a single item using sql.<T> 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- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getConnection
public Connection getConnection(boolean pragmaFk) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryThis method initialize the SQLite connection and driver check- Specified by:
getConnectionin interfaceISqliteRepository- 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- 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- 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- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getSingle
public <T> 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- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getSingle
public <T> 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- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getList
public <T> 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- Returns:
- Throws:
SQLExceptionSqliteDriverNotFoundException
-
getList
public <T> 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- 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- Throws:
SQLExceptionSqliteDriverNotFoundException
-
alterTable
public void alterTable(String sql) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryMethod that handles alter table- Specified by:
alterTablein interfaceISqliteRepository- Throws:
SQLExceptionSqliteDriverNotFoundException
-
dropTable
public void dropTable(String sql) throws SQLException, SqliteDriverNotFoundException
Description copied from interface:ISqliteRepositoryMethod that handles drop table- Specified by:
dropTablein interfaceISqliteRepository- Throws:
SQLExceptionSqliteDriverNotFoundException
-
-