@Override public T call() throws Exception { dao.update(entity); return entity; } });
break; case Update: operation.dao.update(operation.parameter); break; case UpdateInTxIterable:
/** Convenient call for {@link AbstractDao#update(Object)}. */ public <T> void update(T entity) { @SuppressWarnings("unchecked") AbstractDao<T, ?> dao = (AbstractDao<T, ?>) getDao(entity.getClass()); dao.update(entity); }
break; case Update: operation.dao.update(operation.parameter); break; case UpdateInTxIterable:
/** * "Saves" an entity to the database: depending on the existence of the key property, it will be inserted * (key is null) or updated (key is not null). * <p> * This is similar to {@link #insertOrReplace(Object)}, but may be more efficient, because if a key is present, * it does not have to query if that key already exists. */ public void save(T entity) { if (hasKey(entity)) { update(entity); } else { insert(entity); } }
public void testUpdate() { dao.deleteAll(); T entity = createEntityWithRandomPk(); dao.insert(entity); dao.update(entity); assertEquals(1, dao.count()); }
protected void runOneByOneTests(List<T> list, int loadCount, int modifyCount) { dao.insertInTx(list); List<K> keys = new ArrayList<K>(loadCount); for (int i = 0; i < loadCount; i++) { keys.add(daoAccess.getKey(list.get(i))); } clearIdentityScopeIfAny(); list = runLoadOneByOne(keys, "load-one-by-one-1"); list = runLoadOneByOne(keys, "load-one-by-one-2"); Debug.stopMethodTracing(); dao.deleteAll(); startClock("insert-one-by-one"); for (int i = 0; i < modifyCount; i++) { dao.insert(list.get(i)); } stopClock(); startClock("update-one-by-one"); for (int i = 0; i < modifyCount; i++) { dao.update(list.get(i)); } stopClock(); startClock("delete-one-by-one"); for (int i = 0; i < modifyCount; i++) { dao.delete(list.get(i)); } stopClock(); }
@Override public T call() throws Exception { dao.update(entity); return entity; } });
public void update(T item) { mDao.update(item); }
/** Convenient call for {@link AbstractDao#update(Object)}. */ public <T> void update(T entity) { @SuppressWarnings("unchecked") AbstractDao<T, ?> dao = (AbstractDao<T, ?>) getDao(entity.getClass()); dao.update(entity); }
/** * "Saves" an entity to the database: depending on the existence of the key property, it will be inserted * (key is null) or updated (key is not null). * <p> * This is similar to {@link #insertOrReplace(Object)}, but may be more efficient, because if a key is present, * it does not have to query if that key already exists. */ public void save(T entity) { if (hasKey(entity)) { update(entity); } else { insert(entity); } }
public void testUpdate() { dao.deleteAll(); T entity = createEntityWithRandomPk(); dao.insert(entity); dao.update(entity); assertEquals(1, dao.count()); }