@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
protected void checkCached() { if (entities == null) { throw new DaoException("This operation only works with cached lazy lists"); } }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
@Generated private void __throwIfDetached() { if (myDao == null) { throw new DaoException("Entity is detached from DAO context"); } }
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; } }
public AbstractDao<?, ?> getDao(Class<? extends Object> entityClass) { AbstractDao<?, ?> dao = entityToDao.get(entityClass); if (dao == null) { throw new DaoException("No DAO registered for " + entityClass); } return dao; }
protected void checkThread() { if (Thread.currentThread() != ownerThread) { throw new DaoException( "Method may be called only in owner thread, use forCurrentThread to get an instance for this thread"); } }
/** Lock must be locked when entering this method. */ protected E loadEntity(int location) { boolean ok = cursor.moveToPosition(location); if(!ok) { throw new DaoException("Could not move to cursor location " + location); } E entity = daoAccess.loadCurrent(cursor, 0, true); if (entity == null) { throw new DaoException("Loading of entity failed (null) at position " + location); } return entity; }
@Generated public void setTestNotNull(TestEntity testNotNull) { if (testNotNull == null) { throw new DaoException("To-one property 'testIdNotNull' has not-null constraint; cannot set to-one to null"); } synchronized (this) { this.testNotNull = testNotNull; testIdNotNull = testNotNull.getId(); testNotNull__resolvedKey = testIdNotNull; } }
/** Creates an select for given columns with a trailing space */ public static String createSqlSelect(String tablename, String tableAlias, String[] columns, boolean distinct) { if (tableAlias == null || tableAlias.length() < 0) { throw new DaoException("Table alias required"); } StringBuilder builder = new StringBuilder(distinct ? "SELECT DISTINCT " : "SELECT "); SqlUtils.appendColumns(builder, tableAlias, columns).append(" FROM "); builder.append('"').append(tablename).append('"').append(' ').append(tableAlias).append(' '); return builder.toString(); }
/** * Waits until all enqueued operations are complete. If the thread gets interrupted, any * {@link InterruptedException} will be rethrown as a {@link DaoException}. */ public synchronized void waitForCompletion() { while (!isCompleted()) { try { wait(); } catch (InterruptedException e) { throw new DaoException("Interrupted while waiting for all operations to complete", e); } } }
/** See {@link #getKey(Object)}, but guarantees that the returned key is never null (throws if null). */ protected K getKeyVerified(T entity) { K key = getKey(entity); if (key == null) { if (entity == null) { throw new NullPointerException("Entity may not be null"); } else { throw new DaoException("Entity has no key"); } } else { return key; } }
/** * Executes the query and returns the unique result (never null). * * @return Entity * @throws DaoException if the result is not unique or no entity was found */ public T uniqueOrThrow() { T entity = unique(); if (entity == null) { throw new DaoException("No entity found for query"); } return entity; }
void checkProperty(Property property) { if (dao != null) { Property[] properties = dao.getProperties(); boolean found = false; for (Property property2 : properties) { if (property == property2) { found = true; break; } } if (!found) { throw new DaoException("Property '" + property.name + "' is not part of " + dao); } } }
protected T loadUnique(Cursor cursor) { boolean available = cursor.moveToFirst(); if (!available) { return null; } else if (!cursor.isLast()) { throw new DaoException("Expected unique result, but count was " + cursor.getCount()); } return loadCurrent(cursor, 0, true); }
private void deleteByKeyInsideSynchronized(K key, DatabaseStatement stmt) { if (key instanceof Long) { stmt.bindLong(1, (Long) key); } else if (key == null) { throw new DaoException("Cannot delete entity, key is null"); } else { stmt.bindString(1, key.toString()); } stmt.execute(); }
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); }