use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DeleteDAOImpl method deleteByFieldIsValue.
public <T> Number deleteByFieldIsValue(Class<T> clazz, String[] fields, String[] values) throws DAOException {
Number id = 0;
if (clazz != null && fields != null && values != null && fields.length == values.length) {
Connection con = null;
try {
con = ds.getConnection();
Sql[] sqls = SqlFactory.getDeleteSql(new Object[] { clazz.newInstance() }).delete(fields, values);
id = JdbcUtil.updateWithArgs(con, sqls[0].sql, sqls[0].args.toArray());
} catch (Exception e) {
throw new DAOException("", e);
}
}
return id;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class UpdateDAOImpl method updateBySQLWithArgs.
public <T> Number[] updateBySQLWithArgs(String[] sqls, Object[][] args) throws DAOException {
Number[] result = null;
Connection con = null;
try {
con = ds.getConnection();
result = JdbcUtil.updateWithArgs(con, sqls, args);
} catch (Exception e) {
throw new DAOException("updateBySQLWithArgs exception ", e);
}
return result;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class UpdateDAOImpl method updateBySQL.
public <T> Number[] updateBySQL(String... sqls) throws DAOException {
Number[] result = null;
Connection con = null;
try {
con = ds.getConnection();
result = JdbcUtil.update(con, sqls);
} catch (Exception e) {
throw new DAOException("updateBySQL exception ", e);
}
return result;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class UpdateDAOImpl method updateByFieldIsValue.
public <T> Number[] updateByFieldIsValue(T[] ts, String[] fields, String[] values) throws DAOException {
Number[] ids = null;
if (ts != null && ts.length > 0 && fields != null && fields.length > 0) {
Connection con = null;
ids = new Number[ts.length];
try {
Sql[] sqls = SqlFactory.getUpdateSql(ts).update(fields, values);
for (int i = 0; i < ts.length; i++) {
con = ds.getConnection();
ids[i] = JdbcUtil.updateWithArgs(con, sqls[i].sql, sqls[i].args.toArray());
// 更新缓存
}
} catch (Exception e) {
throw new DAOException("updateByFieldIsValue exception ", e);
}
}
return ids;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DeleteDAOImpl method deleteWhere.
public <T> Number deleteWhere(Class<T> clazz, String condition, Object[] args) throws DAOException {
Number id = 0;
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
Sql sql = SqlFactory.getDeleteSql(new Object[] { clazz.newInstance() }).deleteWhere(ORMConfigBeanUtil.parseQuery(condition, clazz));
id = JdbcUtil.updateWithArgs(con, sql.sql, args);
// 缓存
} catch (Exception e) {
throw new DAOException("", e);
}
}
return id;
}
Aggregations