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; } }
public void save(Object entity) throws DbException { try { beginTransaction(); createTableIfNotExist(entity.getClass()); execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity)); setTransactionSuccessful(); } finally { endTransaction(); } }
public void saveAll(List<?> entities) throws DbException { if (entities == null || entities.size() == 0) return; try { beginTransaction(); createTableIfNotExist(entities.get(0).getClass()); for (Object entity : entities) { execNonQuery(SqlInfoBuilder.buildInsertSqlInfo(this, entity)); } setTransactionSuccessful(); } finally { endTransaction(); } }