use of org.eweb4j.orm.dao.DAOException in project eweb4j-framework by laiweiwei.
the class SearchDAOImpl method searchByDivPage.
public <T> List<T> searchByDivPage(Class<T> clazz, String[] fields, String[] values, int likeType, boolean isLike, boolean isNot, boolean isOR, String orderField, int oType, int currentPage, int numPerPage) 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, 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 SearchDAOImpl method search.
public <T> List<T> search(T t, String[] fields, int likeType, boolean isLike, boolean isNot, boolean isOR, String orderField, int oType) 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, 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 SelectDAOImpl method selectAll.
public <T> List<T> selectAll(Class<T> clazz, String orderField, int orderType) throws DAOException {
List<T> list = null;
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
String sql = SqlFactory.getSelectSql(clazz.newInstance(), dbType).selectAll(orderField, orderType);
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, Object... args) 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, args));
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(Class<T> clazz, String[] fields, String[] values) throws DAOException {
T result = null;
if (clazz != null) {
Connection con = null;
try {
con = ds.getConnection();
T t = clazz.newInstance();
String sql = SqlFactory.getSelectSql(t, dbType).selectWhere(fields, values);
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