use of com.lidroid.xutils.db.table.Table in project xUtils by wyouflf.
the class DbUtils method saveBindingIdWithoutTransaction.
private boolean saveBindingIdWithoutTransaction(Object entity) throws DbException {
Class<?> entityType = entity.getClass();
Table table = Table.get(this, entityType);
Id idColumn = table.id;
if (idColumn.isAutoIncrement()) {
execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity));
long id = getLastAutoIncrementId(table.tableName);
if (id == -1) {
return false;
}
idColumn.setAutoIncrementId(entity, id);
return true;
} else {
execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity));
return true;
}
}
use of com.lidroid.xutils.db.table.Table in project xUtils by wyouflf.
the class FinderLazyLoader method getFirstFromDb.
public T getFirstFromDb() throws DbException {
T entity = null;
Table table = finderColumn.getTable();
if (table != null) {
entity = table.db.findFirst(Selector.from(finderColumn.getTargetEntityType()).where(finderColumn.getTargetColumnName(), "=", finderValue));
}
return entity;
}
use of com.lidroid.xutils.db.table.Table in project xUtils by wyouflf.
the class ForeignLazyLoader method getAllFromDb.
public List<T> getAllFromDb() throws DbException {
List<T> entities = null;
Table table = foreignColumn.getTable();
if (table != null) {
entities = table.db.findAll(Selector.from(foreignColumn.getForeignEntityType()).where(foreignColumn.getForeignColumnName(), "=", columnValue));
}
return entities;
}
use of com.lidroid.xutils.db.table.Table in project xUtils by wyouflf.
the class FinderLazyLoader method getAllFromDb.
public List<T> getAllFromDb() throws DbException {
List<T> entities = null;
Table table = finderColumn.getTable();
if (table != null) {
entities = table.db.findAll(Selector.from(finderColumn.getTargetEntityType()).where(finderColumn.getTargetColumnName(), "=", finderValue));
}
return entities;
}
use of com.lidroid.xutils.db.table.Table in project xUtils by wyouflf.
the class DbUtils method count.
public long count(Selector selector) throws DbException {
Class<?> entityType = selector.getEntityType();
if (!tableIsExist(entityType))
return 0;
Table table = Table.get(this, entityType);
DbModelSelector dmSelector = selector.select("count(" + table.id.getColumnName() + ") as count");
return findDbModelFirst(dmSelector).getLong("count");
}
Aggregations