use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.
the class TidbDialect method load.
/*
* (non-Javadoc)
*
* @see org.sagacity.sqltoy.dialect.Dialect#load(java.io.Serializable,
* java.util.List, java.sql.Connection)
*/
@Override
public Serializable load(final SqlToyContext sqlToyContext, Serializable entity, List<Class> cascadeTypes, LockMode lockMode, Connection conn, final Integer dbType, final String dialect, final String tableName) throws Exception {
EntityMeta entityMeta = sqlToyContext.getEntityMeta(entity.getClass());
// 获取loadsql(loadsql 可以通过@loadSql进行改变,所以需要sqltoyContext重新获取)
SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(entityMeta.getLoadSql(tableName), SqlType.search, dialect);
String loadSql = sqlToyConfig.getSql(dialect);
loadSql = loadSql.concat(getLockSql(loadSql, dbType, lockMode));
return (Serializable) DialectUtils.load(sqlToyContext, sqlToyConfig, loadSql, entityMeta, entity, cascadeTypes, conn, dbType);
}
use of org.sagacity.sqltoy.config.model.SqlToyConfig 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.config.model.SqlToyConfig 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.config.model.SqlToyConfig 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.config.model.SqlToyConfig 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