@Override protected final void attachEntity(ToManyEntity entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(TreeEntity entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(RelationSource2 entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(RelationEntity entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(AnActiveEntity entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
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)"); } }
/** * Attaches the entity to the identity scope. Calls attachEntity(T entity). * * @param key Needed only for identity scope, pass null if there's none. * @param entity The entitiy to attach */ protected final void attachEntity(K key, T entity, boolean lock) { attachEntity(entity); if (identityScope != null && key != null) { if (lock) { identityScope.put(key, entity); } else { identityScope.putNoLock(key, entity); } } }
/** Resets all locally changed properties of the entity by reloading the values from the database. */ public void refresh(T entity) { assertSinglePk(); K key = getKeyVerified(entity); String sql = statements.getSelectByKey(); String[] keyArray = new String[]{key.toString()}; Cursor cursor = db.rawQuery(sql, keyArray); try { boolean available = cursor.moveToFirst(); if (!available) { throw new DaoException("Entity does not exist in the database anymore: " + entity.getClass() + " with key " + key); } else if (!cursor.isLast()) { throw new DaoException("Expected unique result, but count was " + cursor.getCount()); } readEntity(cursor, entity, 0); attachEntity(key, entity, true); } finally { cursor.close(); } }
protected void updateInsideSynchronized(T entity, DatabaseStatement stmt, boolean lock) { // To do? Check if it's worth not to bind PKs here (performance). bindValues(stmt, entity); int index = config.allColumns.length + 1; K key = getKey(entity); if (key instanceof Long) { stmt.bindLong(index, (Long) key); } else if (key == null) { throw new DaoException("Cannot update entity without key - was it inserted before?"); } else { stmt.bindString(index, key.toString()); } stmt.execute(); attachEntity(key, entity, lock); }
protected void updateInsideSynchronized(T entity, SQLiteStatement stmt, boolean lock) { // To do? Check if it's worth not to bind PKs here (performance). bindValues(stmt, entity); int index = config.allColumns.length + 1; K key = getKey(entity); if (key instanceof Long) { stmt.bindLong(index, (Long) key); } else if (key == null) { throw new DaoException("Cannot update entity without key - was it inserted before?"); } else { stmt.bindString(index, key.toString()); } stmt.execute(); attachEntity(key, entity, lock); }
} else { entity = readEntity(cursor, offset); attachEntity(entity); if (lock) { identityScopeLong.put2(key, entity); } else { entity = readEntity(cursor, offset); attachEntity(key, entity, lock); return entity; attachEntity(entity); return entity;
@Override protected final void attachEntity(FollowerLink entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(ContactLink entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(Thread entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(Message entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(ThreadMetaValue entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(User entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(UserMetaValue entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(UserThreadLink entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }
@Override protected final void attachEntity(ReadReceiptUserLink entity) { super.attachEntity(entity); entity.__setDaoSession(daoSession); }