use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.
the class TranslateFactory method getSqlCacheData.
/**
* @todo 通过sql查询获取缓存数据
* @param sqlToyContext
* @param cacheModel
* @param cacheType
* @return
* @throws Exception
*/
private static List getSqlCacheData(final SqlToyContext sqlToyContext, TranslateConfigModel cacheModel, String cacheType) throws Exception {
final SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(cacheModel.getSql(), SqlType.search, "");
QueryExecutor queryExecutor = null;
if (StringUtil.isBlank(cacheType)) {
queryExecutor = new QueryExecutor(cacheModel.getSql());
} else {
queryExecutor = new QueryExecutor(cacheModel.getSql(), sqlToyConfig.getParamsName(), new Object[] { cacheType.trim() });
}
String dataSourceName = cacheModel.getDataSource();
if (dataSourceName == null) {
dataSourceName = sqlToyConfig.getDataSource();
}
DataSourceSelector dataSourceSelector = sqlToyContext.getDataSourceSelector();
DataSource dataSource = dataSourceSelector.getDataSource(sqlToyContext.getApplicationContext(), null, dataSourceName, null, sqlToyContext.getDefaultDataSource());
return DialectFactory.getInstance().findByQuery(sqlToyContext, queryExecutor, sqlToyConfig, null, dataSource).getRows();
}
use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.
the class SqlToyDaoSupport method getCountByQuery.
/**
* @todo 指定数据源查询记录数量
* @param queryExecutor
* @return
*/
protected Long getCountByQuery(final QueryExecutor queryExecutor) {
QueryExecutorExtend extend = queryExecutor.getInnerModel();
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(extend.sql, SqlType.search, getDialect(extend.dataSource));
return dialectFactory.getCountBySql(sqlToyContext, queryExecutor, sqlToyConfig, this.getDataSource(extend.dataSource, sqlToyConfig));
}
Aggregations