use of org.sagacity.sqltoy.model.QueryExecutor in project sagacity-sqltoy by chenrenfei.
the class ParallQueryExecutor method call.
@Override
public ParallQueryResult call() {
ParallQueryResult result = new ParallQueryResult();
try {
ParallQueryExtend extend = parallQuery.getExtend();
QueryExecutor queryExecutor = new QueryExecutor(extend.sql).resultType(extend.resultType).names(paramNames).values(paramValues);
// 分页
if (extend.page != null) {
result.setResult(dialectFactory.findPage(sqlToyContext, queryExecutor, sqlToyConfig, extend.page.getPageNo(), extend.page.getPageSize(), dataSource));
} else {
result.setResult(dialectFactory.findByQuery(sqlToyContext, queryExecutor, sqlToyConfig, null, dataSource));
}
} catch (Exception e) {
result.setSuccess(false);
result.setMessage(e.getMessage());
}
return result;
}
use of org.sagacity.sqltoy.model.QueryExecutor in project sagacity-sqltoy by chenrenfei.
the class Query method findTop.
/**
* @todo 取前多少条记录
* @param topSize
* @return
*/
public List<?> findTop(final double topSize) {
QueryExecutor queryExecute = build();
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(queryExecute, SqlType.search, getDialect());
QueryResult result = dialectFactory.findTop(sqlToyContext, queryExecute, sqlToyConfig, topSize, getDataSource(sqlToyConfig));
return result.getRows();
}
use of org.sagacity.sqltoy.model.QueryExecutor in project sagacity-sqltoy by chenrenfei.
the class Query method count.
/**
* @todo 查询记录集的数量
* @return
*/
public Long count() {
QueryExecutor queryExecute = build();
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(queryExecute, SqlType.search, getDialect());
return dialectFactory.getCountBySql(sqlToyContext, queryExecute, sqlToyConfig, getDataSource(sqlToyConfig));
}
use of org.sagacity.sqltoy.model.QueryExecutor in project sagacity-sqltoy by chenrenfei.
the class Query method getValue.
/**
* @todo 获取单值
* @return
*/
public Object getValue() {
QueryExecutor queryExecute = new QueryExecutor(sql).names(names).values(values);
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(queryExecute, SqlType.search, getDialect());
QueryResult result = dialectFactory.findByQuery(sqlToyContext, queryExecute, sqlToyConfig, null, getDataSource(sqlToyConfig));
List rows = result.getRows();
if (rows != null && rows.size() > 0) {
return ((List) rows.get(0)).get(0);
}
return null;
}
use of org.sagacity.sqltoy.model.QueryExecutor in project sagacity-sqltoy by chenrenfei.
the class Query method findPage.
/**
* @TODO 进行分页查询
* @param page
* @return
*/
public Page<?> findPage(final Page page) {
QueryExecutor queryExecute = build();
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(queryExecute, SqlType.search, getDialect());
if (page.getSkipQueryCount()) {
return (Page<?>) dialectFactory.findSkipTotalCountPage(sqlToyContext, queryExecute, sqlToyConfig, page.getPageNo(), page.getPageSize(), getDataSource(sqlToyConfig)).getPageResult();
}
return (Page<?>) dialectFactory.findPage(sqlToyContext, queryExecute, sqlToyConfig, page.getPageNo(), page.getPageSize(), getDataSource(sqlToyConfig)).getPageResult();
}
Aggregations