use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class DivPageDAOImpl method divPageByFieldIsValue.
public <T> List<T> divPageByFieldIsValue(Class<T> clazz, String[] fields, String[] values, String orderField, int orderType, int currPage, int numPerPage, boolean isOR) throws DAOException {
List<T> list = null;
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
String sql = SqlFactory.getSelectSql(clazz.newInstance(), dbType).selectWhere(fields, values, -2, false, false, isOR, orderField, orderType, currPage, numPerPage);
list = JdbcUtil.getList(con, clazz, sql);
} catch (Exception e) {
throw new DAOException("divPageByFieldIsValue exception ", e);
}
}
return list;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class SearchDAOImpl method search.
public <T> List<T> search(Class<T> clazz, String[] fields, String[] values, int likeType, boolean isLike, boolean isNot, boolean isOR, String orderField, int oType) throws DAOException {
List<T> list = null;
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
T t = clazz.newInstance();
String sql = SqlFactory.getSelectSql(t, dbType).selectWhere(fields, values, likeType, isLike, isNot, isOR, orderField, oType, -1, -1);
list = JdbcUtil.getList(con, clazz, sql);
} catch (Exception e) {
throw new DAOException("", e);
}
}
return list;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class SearchDAOImpl method searchByDivPage.
public <T> List<T> searchByDivPage(T t, String[] fields, int likeType, boolean isLike, boolean isNot, boolean isOR, String orderField, int oType, int currentPage, int numPerPage) throws DAOException {
List<T> list = null;
if (t != null) {
Connection con = null;
@SuppressWarnings("unchecked") Class<T> clazz = (Class<T>) t.getClass();
try {
con = ds.getConnection();
String sql = SqlFactory.getSelectSql(t, dbType).selectWhere(fields, likeType, isLike, isNot, isOR, orderField, oType, currentPage, numPerPage);
list = JdbcUtil.getList(con, clazz, sql);
} catch (Exception e) {
throw new DAOException("", e);
}
}
return list;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class SelectDAOImpl method selectCount.
public <T> long selectCount(Class<T> clazz, String condition) throws DAOException {
long result = -1;
Connection con = null;
try {
con = ds.getConnection();
if (clazz != null) {
T t = clazz.newInstance();
String sql = SqlFactory.getSelectSql(t, dbType).selectCount(ORMConfigBeanUtil.parseQuery(condition, clazz));
String str = String.valueOf(JdbcUtil.getObject(con, sql));
if (CommonUtil.isNumeric(str)) {
result = Integer.parseInt(str);
}
}
} catch (Exception e) {
throw new DAOException("", e);
}
return result;
}
use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class SelectDAOImpl method selectOne.
public <T> T selectOne(T t, String... fields) throws DAOException {
T result = 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);
List<T> list = JdbcUtil.getList(con, clazz, sql);
if (list != null && !list.isEmpty()) {
result = list.get(0);
}
} catch (Exception e) {
throw new DAOException("", e);
}
}
return result;
}
Aggregations