protected void setUpTableForDao() throws Exception { try { Method createTableMethod = daoClass.getMethod("createTable", Database.class, boolean.class); createTableMethod.invoke(null, db, false); } catch (NoSuchMethodException e) { DaoLog.i("No createTable method"); } }
public void testGetForCurrentThread_ManyThreadsDontLeak() throws Exception { if (VERSION.SDK_INT > VERSION_CODES.LOLLIPOP_MR1) { DaoLog.i("testGetForCurrentThread_ManyThreadsDontLeak does not work on API level " + VERSION.SDK_INT); return; Map map = (Map) mapField.get(queryData); for (int i = 0; map.size() > 1 && i < 1000; i++) { DaoLog.d("Queries left after " + i + ". GC: " + map.size()); System.gc(); gcMethod.invoke(queryData);
protected void updateKeyAfterInsertAndAttach(T entity, long rowId, boolean lock) { if (rowId != -1) { K key = updateKeyAfterInsert(entity, rowId); attachEntity(key, entity, lock); } else { // TODO When does this actually happen? Should we throw instead? DaoLog.w("Could not insert row (executeInsert returned -1)"); } }
public void testQueryRaw() { List<SqliteMaster> tables = dao.queryRaw("WHERE " + Properties.Type.columnName + "=?", "table"); for (SqliteMaster table : tables) { DaoLog.v(table.toString()); } }
protected void logTableDump(String tablename) { if (db instanceof StandardDatabase) { DbUtils.logTableDump(((StandardDatabase) db).getSQLiteDatabase(), tablename); } else { DaoLog.w("Table dump unsupported for " + db); } }
public void testLoadAll() { List<SqliteMaster> all = dao.loadAll(); for (SqliteMaster meta : all) { DaoLog.v(meta.toString()); } }
@Override public boolean onCreate() { // if(daoSession == null) { // throw new IllegalStateException("DaoSession must be set before content provider is created"); // } DaoLog.d("Content Provider started: " + CONTENT_URI); return true; }
/** * Executes the given SQL asset in the given database (SQL file should be UTF-8). The database file may contain * multiple SQL statements. Statements are split using a simple regular expression (something like * "semicolon before a line break"), not by analyzing the SQL syntax. This will work for many SQL files, but check * yours. * * @return number of statements executed. */ public static int executeSqlScript(Context context, Database db, String assetFilename, boolean transactional) throws IOException { byte[] bytes = readAsset(context, assetFilename); String sql = new String(bytes, "UTF-8"); String[] lines = sql.split(";(\\s)*[\n\r]"); int count; if (transactional) { count = executeSqlStatementsInTx(db, lines); } else { count = executeSqlStatements(db, lines); } DaoLog.i("Executed " + count + " statements from SQL script '" + assetFilename + "'"); return count; }
DaoLog.w(Thread.currentThread().getName() + " was interruppted", e);
DaoLog.e("Sorry, we need at least API level 16 for WAL"); return;
public void testIndexesCreated() { Assert.assertEquals(0, getIndexes().size()); TestEntityDao.createTable(db, false); List<SqliteMaster> indexes = getIndexes(); Assert.assertEquals(2, indexes.size()); SqliteMaster index1 = indexes.get(0); SqliteMaster index2 = indexes.get(1); Assert.assertEquals(TestEntityDao.TABLENAME, index1.getTableName()); Assert.assertEquals(TestEntityDao.TABLENAME, index2.getTableName()); Assert.assertEquals("IDX_TEST_ENTITY_INDEXED_STRING", index1.getName()); Assert.assertEquals("IDX_TEST_ENTITY_INDEXED_STRING_ASC_UNIQUE", index2.getName()); for (SqliteMaster index : indexes) { DaoLog.v(index.toString()); } }
public void logStats() { int collisions = 0; for (Entry<T> entry : table) { while (entry != null && entry.next != null) { collisions++; entry = entry.next; } } DaoLog.d("load: " + ((float) size) / capacity + ", size: " + size + ", capa: " + capacity + ", collisions: " + collisions + ", collision ratio: " + ((float) collisions) / size); }
db.endTransaction(); } catch (RuntimeException e) { DaoLog.i("Async transaction could not be ended, success so far was: " + success, e); success = false; DaoLog.i("Reverted merged transaction because one of the operations failed. Executing operations one by " + "one instead..."); for (AsyncOperation asyncOperation : mergedOps) {
} catch (RuntimeException e) { if (txEx != null) { DaoLog.w("Could not end transaction (rethrowing initial exception)", e); throw txEx; } else {
protected void setUpTableForDao() throws Exception { try { Method createTableMethod = daoClass.getMethod("createTable", Database.class, boolean.class); createTableMethod.invoke(null, db, false); } catch (NoSuchMethodException e) { DaoLog.i("No createTable method"); } }
protected void logTableDump(String tablename) { if (db instanceof StandardDatabase) { DbUtils.logTableDump(((StandardDatabase) db).getSQLiteDatabase(), tablename); } else { DaoLog.w("Table dump unsupported for " + db); } }