/** Convenient call for {@link AbstractDao#queryRaw(String, String...)}. */ public <T, K> List<T> queryRaw(Class<T> entityClass, String where, String... selectionArgs) { @SuppressWarnings("unchecked") AbstractDao<T, K> dao = (AbstractDao<T, K>) getDao(entityClass); return dao.queryRaw(where, selectionArgs); }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
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)"); } }
/** Deletes the given entity from the database. Currently, only single value PK entities are supported. */ public void delete(T entity) { assertSinglePk(); K key = getKeyVerified(entity); deleteByKey(key); }
/** Convenient call for {@link AbstractDao#queryBuilder()}. */ public <T> QueryBuilder<T> queryBuilder(Class<T> entityClass) { @SuppressWarnings("unchecked") AbstractDao<T, ?> dao = (AbstractDao<T, ?>) getDao(entityClass); return dao.queryBuilder(); }
@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; }
@Override public Iterable<T> call() throws Exception { dao.insertInTx(entities); return entities; } });
@Override public T call() throws Exception { dao.update(entity); return entity; } });
@Override public T call() throws Exception { dao.save(entity); return entity; } });
@Override public Void call() throws Exception { daoSession.runInTx(runnable); return null; } });
@Override public T call() throws Exception { return daoSession.callInTx(callable); } });
/** * Deletes the given entities in the database using a transaction. * * @param entities The entities to delete. */ public void deleteInTx(Iterable<T> entities) { deleteInTxInternal(entities, null); }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
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); }
protected void assertSinglePk() { if (config.pkColumns.length != 1) { throw new DaoException(this + " (" + config.tablename + ") does not have a single-column primary key"); } }
public long getDuration() { if (timeCompleted == 0) { throw new DaoException("This operation did not yet complete"); } else { return timeCompleted - timeStarted; } }