public abstract class AbstractModel<T> extends Object
Modifier | Constructor and Description |
---|---|
protected |
AbstractModel(String tableName,
String idColumn,
String versionColumn,
String[] queryColumns) |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
bindDelete(android.database.sqlite.SQLiteStatement statement,
T entity) |
protected abstract void |
bindInsert(android.database.sqlite.SQLiteStatement statement,
T entity) |
protected abstract void |
bindUpdate(android.database.sqlite.SQLiteStatement statement,
T entity) |
boolean |
delete(T entity)
Delete entity without transaction.
|
int |
deleteById(long... ids)
Delete entities by ids without transaction.
|
int |
deleteByIdInTx(long... ids)
Delete entities by ids in transaction.
|
int |
deleteInTx(Iterable<T> entities)
Delete entities in transaction.
|
int |
deleteInTx(T... entities)
Delete entities in transaction.
|
boolean |
deleteInTx(T entity)
Delete entity in transaction.
|
protected abstract String |
getDeleteStatement() |
protected abstract long |
getId(T entity) |
protected abstract String |
getInsertStatement() |
protected abstract String |
getUpdateStatement() |
protected long |
getVersion(T entity) |
long |
insert(T entity)
Insert entity without transaction.
|
long[] |
insertInTx(Iterable<T> entities)
Insert entity inside transaction.
|
long[] |
insertInTx(T... entities)
Insert entity inside transaction.
|
long |
insertInTx(T entity)
Insert entity inside transaction.
|
boolean |
isVersionEnabled() |
T |
loadById(long id)
Load entity by id (result will be cached).
|
protected abstract T |
newInstance() |
protected abstract void |
onCreate(android.database.sqlite.SQLiteDatabase db) |
List<T> |
rawQuery(String selection,
String[] selectionArg,
String orderBy,
String limit)
Raw query for result (result will not be cached).
|
List<T> |
rawQuery(String selection,
String[] selectionArg,
String groupBy,
String having,
String orderBy,
String limit)
Raw query for result (result will not be cached).
|
T |
rawQuerySingle(String selection,
String[] selectionArg)
Raw query for single result (result will not be cached).
|
T |
rawQuerySingle(String selection,
String[] selectionArg,
String having)
Raw query for single result (result will not be cached).
|
protected abstract void |
readCursor(T entity,
android.database.Cursor cursor) |
boolean |
update(T entity)
Update entity without transaction.
|
int |
updateInTx(Iterable<T> entities)
Update entity inside transaction.
|
boolean |
updateInTx(android.database.sqlite.SQLiteDatabase db,
T entity)
Update entity inside transaction.
|
int |
updateInTx(T... entities)
Update entity inside transaction.
|
public T rawQuerySingle(String selection, String[] selectionArg)
selection
- selectionselectionArg
- selection argument.public T rawQuerySingle(String selection, String[] selectionArg, String having)
selection
- selectionselectionArg
- selection argument.having
- having clause.public List<T> rawQuery(String selection, String[] selectionArg, String orderBy, String limit)
selection
- selectionselectionArg
- selection argument.orderBy
- having clause.limit
- limit clause.public List<T> rawQuery(String selection, String[] selectionArg, String groupBy, String having, String orderBy, String limit)
selection
- selectionselectionArg
- selection argument.groupBy
- groupBy clause.having
- having clause.orderBy
- having clause.limit
- limit clause.public T loadById(long id)
id
- entity idpublic long[] insertInTx(T... entities)
entities
- entities to insert.public long[] insertInTx(Iterable<T> entities)
entities
- entities to insert.public long insertInTx(T entity)
entity
- entity to insert.public long insert(T entity)
entity
- entity to insert.public int updateInTx(T... entities)
entities
- entities to update.public int updateInTx(Iterable<T> entities)
entities
- entities to update.public boolean updateInTx(android.database.sqlite.SQLiteDatabase db, T entity)
db
- database.entity
- entity to update.public boolean update(T entity)
entity
- entity to update.public int deleteById(long... ids)
ids
- entities to delete ids.public int deleteByIdInTx(long... ids)
ids
- entities to delete ids.public int deleteInTx(T... entities)
entities
- entities to delete.public int deleteInTx(Iterable<T> entities)
entities
- entities to delete.public boolean deleteInTx(T entity)
entity
- entity to delete.public boolean delete(T entity)
entity
- entity to delete.public boolean isVersionEnabled()
protected abstract long getId(T entity)
protected long getVersion(T entity)
protected abstract T newInstance()
protected abstract void readCursor(T entity, android.database.Cursor cursor)
protected abstract void onCreate(android.database.sqlite.SQLiteDatabase db)
protected abstract String getInsertStatement()
protected abstract void bindInsert(android.database.sqlite.SQLiteStatement statement, T entity)
protected abstract String getUpdateStatement()
protected abstract void bindUpdate(android.database.sqlite.SQLiteStatement statement, T entity)
protected abstract String getDeleteStatement()
protected abstract void bindDelete(android.database.sqlite.SQLiteStatement statement, T entity)
Copyright © 2015. All Rights Reserved.