use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class UpdateDAOImpl method batchUpdate.
public <T> Number[] batchUpdate(T[] ts, String... fields) throws DAOException {
Number[] ids = null;
if (ts != null && ts.length > 0) {
Connection con = null;
ids = new Number[ts.length];
try {
con = ds.getConnection();
Sql[] sqls = SqlFactory.getUpdateSql(ts).update(fields);
List<Object[]> argList = new ArrayList<Object[]>(ts.length);
for (Sql sql : sqls) {
argList.add(sql.args.toArray());
}
Object[][] args = new Object[argList.size()][];
for (int i = 0; i < argList.size(); i++) {
args[i] = argList.get(i);
}
ids = JdbcUtil.batchUpdateWithArgs(con, sqls[0].sql, args);
} catch (Exception e) {
throw new DAOException("batchUpdate exception ", e);
}
}
return ids;
}
Aggregations