protected class DefaultStorIOSQLite.LowLevelImpl extends StorIOSQLite.Internal
StorIOSQLite, we made it separate
to make StorIOSQLite API clean and easy to understand.| Modifier | Constructor and Description |
|---|---|
protected |
LowLevelImpl(TypeMappingFinder typeMappingFinder) |
| Modifier and Type | Method and Description |
|---|---|
void |
beginTransaction()
Begins a transaction in EXCLUSIVE mode.
|
int |
delete(DeleteQuery deleteQuery)
Deletes one or multiple rows in the database.
|
void |
endTransaction()
Ends a transaction.
|
void |
executeSQL(RawQuery rawQuery)
Executes a single SQL statement that
is NOT a SELECT/INSERT/UPDATE/DELETE on the database.
|
long |
insert(InsertQuery insertQuery,
android.content.ContentValues contentValues)
Inserts a row into the database.
|
long |
insertWithOnConflict(InsertQuery insertQuery,
android.content.ContentValues contentValues,
int conflictAlgorithm)
Inserts a row into the database.
|
void |
notifyAboutChanges(Changes changes)
Notifies subscribers about changes happened in
StorIOSQLite. |
android.database.Cursor |
query(Query query)
Executes query on the database and returns
Cursor
over the result set. |
android.database.Cursor |
rawQuery(RawQuery rawQuery)
Executes raw query on the database
and returns
Cursor over the result set. |
void |
setTransactionSuccessful()
Marks the current transaction as successful.
|
android.database.sqlite.SQLiteOpenHelper |
sqliteOpenHelper()
Returns
SQLiteOpenHelper for the direct access to underlining database. |
<T> SQLiteTypeMapping<T> |
typeMapping(java.lang.Class<T> type)
Gets type mapping for required type.
|
int |
update(UpdateQuery updateQuery,
android.content.ContentValues contentValues)
Updates one or multiple rows in the database.
|
protected LowLevelImpl(@NonNull
TypeMappingFinder typeMappingFinder)
@Nullable public <T> SQLiteTypeMapping<T> typeMapping(@NonNull java.lang.Class<T> type)
This implementation can handle subclasses of types, that registered its type mapping.
For example: You've added type mapping for User.class,
and you have UserFromServiceA.class which extends User.class,
and you didn't add type mapping for UserFromServiceA.class
because they have same fields and you just want to have multiple classes.
This implementation will find type mapping of User.class
and use it as type mapping for UserFromServiceA.class.
typeMapping in class StorIOSQLite.LowLevelT - type.type - type.null.@WorkerThread
public void executeSQL(@NonNull
RawQuery rawQuery)
executeSQL in class StorIOSQLite.LowLevelrawQuery - sql query.@WorkerThread
@NonNull
public android.database.Cursor rawQuery(@NonNull
RawQuery rawQuery)
Cursor over the result set.rawQuery in class StorIOSQLite.LowLevelrawQuery - sql query@WorkerThread
@NonNull
public android.database.Cursor query(@NonNull
Query query)
Cursor
over the result set.query in class StorIOSQLite.LowLevelquery - sql query.@WorkerThread
public long insert(@NonNull
InsertQuery insertQuery,
@NonNull
android.content.ContentValues contentValues)
insert in class StorIOSQLite.LowLevelinsertQuery - query.contentValues - map that contains the initial column values for the row.
The keys should be the column names and the values the column values.@WorkerThread
public long insertWithOnConflict(@NonNull
InsertQuery insertQuery,
@NonNull
android.content.ContentValues contentValues,
int conflictAlgorithm)
insertWithOnConflict in class StorIOSQLite.LowLevelinsertQuery - query.contentValues - map that contains the initial column values for the row.
The keys should be the column names and the values the column values.conflictAlgorithm - for insert conflict resolver.SQLiteDatabase.CONFLICT_IGNORE
OR -1 if any error.SQLiteDatabase.insertWithOnConflict(String, String, ContentValues, int),
SQLiteDatabase.CONFLICT_REPLACE,
SQLiteDatabase.CONFLICT_ABORT,
SQLiteDatabase.CONFLICT_FAIL,
SQLiteDatabase.CONFLICT_ROLLBACK,
SQLiteDatabase.CONFLICT_IGNORE@WorkerThread
public int update(@NonNull
UpdateQuery updateQuery,
@NonNull
android.content.ContentValues contentValues)
update in class StorIOSQLite.LowLevelupdateQuery - query.contentValues - a map from column names to new column values.
null is a valid value that will be translated to NULL.@WorkerThread
public int delete(@NonNull
DeleteQuery deleteQuery)
delete in class StorIOSQLite.LowLeveldeleteQuery - query.public void notifyAboutChanges(@NonNull
Changes changes)
StorIOSQLite.
Operations can be executed in transaction or one operation can affect multiple tables,
so to reduce number of notifications you can call this method once and
provide aggregated Changes object.notifyAboutChanges in class StorIOSQLite.LowLevelchanges - changes happened in StorIOSQLite.public void beginTransaction()
Thread will be blocked on call to this method if another thread already in transaction, as soon as first thread will end its transaction this thread will be unblocked.
Transactions can be nested. When the outer transaction is ended all of the work done in that transaction and all of the nested transactions will be committed or rolled back. The changes will be rolled back if any transaction is ended without being marked as clean (by calling setTransactionSuccessful). Otherwise they will be committed.
Here is the standard idiom for transactions:
db.beginTransaction();
try {
...
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
beginTransaction in class StorIOSQLite.LowLevelpublic void setTransactionSuccessful()
setTransactionSuccessful in class StorIOSQLite.LowLevelpublic void endTransaction()
StorIOSQLite.LowLevel.beginTransaction() for notes about
how to use this and when transactions are committed and rolled back.endTransaction in class StorIOSQLite.LowLevel@NonNull public android.database.sqlite.SQLiteOpenHelper sqliteOpenHelper()
SQLiteOpenHelper for the direct access to underlining database.
It can be used in cases when StorIOSQLite APIs are not enough.
Notice: Database changes through the direct access
to the SQLiteOpenHelper will not trigger notifications.
If it possible you should use StorIOSQLite methods instead
or call StorIOSQLite.LowLevel.notifyAboutChanges(Changes) manually.
sqliteOpenHelper in class StorIOSQLite.LowLevelSQLiteOpenHelper.