use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class InsertDAOImpl method insertBySql.
public <T> Number insertBySql(Class<T> clazz, String sql, Object... args) throws DAOException {
Number id = 0;
if (sql == null)
return -1;
Connection con = null;
try {
con = ds.getConnection();
id = JdbcUtil.updateWithArgs(con, sql, args);
// if (rs > 0) {
// id = DAOUtil.selectMaxId(clazz, ds.getConnection(), dbType);
// }
} catch (Exception e) {
throw new DAOException("", e);
}
return id;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class InsertDAOImpl method insertByFields.
public <T> Number[] insertByFields(T[] ts, String[] fields) throws DAOException {
Number[] ids = null;
Connection con = null;
if (ts == null || ts.length == 0)
return ids;
ids = new Number[ts.length];
try {
Sql[] sqls = SqlFactory.getInsertSql(ts).createByFields(fields);
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("", e);
}
return ids;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DivPageDAOImpl method divPageByFieldNotIsValue.
public <T> List<T> divPageByFieldNotIsValue(T t, String[] fields, String orderField, int orderType, int currPage, int numPerPage, boolean isOR) throws DAOException {
List<T> list = null;
if (t != null) {
@SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) t.getClass();
Connection con = null;
try {
con = ds.getConnection();
String sql = SqlFactory.getSelectSql(t, dbType).selectWhere(fields, null, -2, false, true, isOR, orderField, orderType, currPage, numPerPage);
list = JdbcUtil.getList(con, clazz, sql);
} catch (Exception e) {
throw new DAOException("divPageByFieldNotIsValue exception ", e);
}
}
return list;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DivPageDAOImpl method nextOne.
public <T> T nextOne(Class<T> clazz, String column, int value) throws DAOException {
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
List<T> list = JdbcUtil.getList(con, clazz, SqlFactory.getSelectSql(clazz.newInstance(), dbType).nextOne(column, value));
return list != null && !list.isEmpty() ? list.get(0) : null;
} catch (Exception e) {
throw new DAOException("nextOne exception ", e);
}
}
return null;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DivPageDAOImpl method divPageByFieldNotIsValues.
public <T> List<T> divPageByFieldNotIsValues(T t, String[] fields, int orderType, int currPage, int numPerPage, boolean isOR) throws DAOException {
List<T> list = null;
if (t != null) {
@SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) t.getClass();
Connection con = null;
try {
con = ds.getConnection();
String sql = SqlFactory.getSelectSql(t, dbType).selectWhere(fields, null, -2, false, true, isOR, null, orderType, currPage, numPerPage);
list = JdbcUtil.getList(con, clazz, sql);
} catch (Exception e) {
throw new DAOException("divPageByFieldNotIsValues exception ", e);
}
}
return list;
}
Aggregations