Search in sources :

Example 1 with Id

use of com.lidroid.xutils.db.table.Id 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;
    }
}
Also used : Table(com.lidroid.xutils.db.table.Table) Id(com.lidroid.xutils.db.table.Id)

Example 2 with Id

use of com.lidroid.xutils.db.table.Id in project xUtils by wyouflf.

the class DbUtils method saveOrUpdateWithoutTransaction.

//***************************** private operations with out transaction *****************************
private void saveOrUpdateWithoutTransaction(Object entity) throws DbException {
    Table table = Table.get(this, entity.getClass());
    Id id = table.id;
    if (id.isAutoIncrement()) {
        if (id.getColumnValue(entity) != null) {
            execNonQuery(SqlInfoBuilder.buildUpdateSqlInfo(this, entity));
        } else {
            saveBindingIdWithoutTransaction(entity);
        }
    } else {
        execNonQuery(SqlInfoBuilder.buildReplaceSqlInfo(this, entity));
    }
}
Also used : Table(com.lidroid.xutils.db.table.Table) Id(com.lidroid.xutils.db.table.Id)

Aggregations

Id (com.lidroid.xutils.db.table.Id)2 Table (com.lidroid.xutils.db.table.Table)2