Search in sources :

Example 71 with SqlToyConfig

use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.

the class Query method find.

/**
 * @todo 查询结果集合
 * @return
 */
public List<?> find() {
    QueryExecutor queryExecute = build();
    SqlToyConfig sqlToyConfig = sqlToyContext.getSqlToyConfig(queryExecute, SqlType.search, getDialect());
    QueryResult result = dialectFactory.findByQuery(sqlToyContext, queryExecute, sqlToyConfig, lockMode, getDataSource(sqlToyConfig));
    return result.getRows();
}
Also used : QueryResult(org.sagacity.sqltoy.model.QueryResult) QueryExecutor(org.sagacity.sqltoy.model.QueryExecutor) SqlToyConfig(org.sagacity.sqltoy.config.model.SqlToyConfig)

Example 72 with SqlToyConfig

use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.

the class GuassDBDialect method load.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.sagacity.sqltoy.dialect.Dialect#load(org.sagacity.sqltoy.
	 * SqlToyContext, java.io.Serializable, java.util.List,
	 * org.sagacity.sqltoy.lock.LockMode, java.sql.Connection)
	 */
@Override
public Serializable load(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);
}
Also used : EntityMeta(org.sagacity.sqltoy.config.model.EntityMeta) Serializable(java.io.Serializable) SqlToyConfig(org.sagacity.sqltoy.config.model.SqlToyConfig)

Example 73 with SqlToyConfig

use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.

the class KingbaseDialect 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);
}
Also used : EntityMeta(org.sagacity.sqltoy.config.model.EntityMeta) Serializable(java.io.Serializable) SqlToyConfig(org.sagacity.sqltoy.config.model.SqlToyConfig)

Example 74 with SqlToyConfig

use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.

the class SqlXMLConfigParseTest method testParseSegmentXML.

/**
 * 测试外部报表平台集成sqltoy传递xml字符串片段解析
 */
@Test
public void testParseSegmentXML() {
    String sql = FileUtil.readFileAsStr("classpath:scripts/report.xml", "UTF-8");
    try {
        SqlToyConfig result = SqlXMLConfigParse.parseSagment(sql, "utf-8", "mysql");
        System.err.println(JSON.toJSONString(result));
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : SqlToyConfig(org.sagacity.sqltoy.config.model.SqlToyConfig) Test(org.junit.jupiter.api.Test)

Example 75 with SqlToyConfig

use of org.sagacity.sqltoy.config.model.SqlToyConfig in project sagacity-sqltoy by chenrenfei.

the class SqlXMLConfigParseTest method testParseSqlXML.

/**
 * 测试外部报表平台集成sqltoy传递xml字符串片段解析
 */
@Test
public void testParseSqlXML() {
    String sql = FileUtil.readFileAsStr("classpath:scripts/sql.xml", "UTF-8");
    try {
        SqlToyConfig result = SqlXMLConfigParse.parseSagment(sql, "utf-8", "mysql");
        System.err.println(JSON.toJSONString(result));
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
Also used : SqlToyConfig(org.sagacity.sqltoy.config.model.SqlToyConfig) Test(org.junit.jupiter.api.Test)

Aggregations

SqlToyConfig (org.sagacity.sqltoy.config.model.SqlToyConfig)82 EntityMeta (org.sagacity.sqltoy.config.model.EntityMeta)22 Serializable (java.io.Serializable)20 QueryExecutor (org.sagacity.sqltoy.model.QueryExecutor)20 QueryResult (org.sagacity.sqltoy.model.QueryResult)20 Connection (java.sql.Connection)19 ArrayList (java.util.ArrayList)19 DataSourceCallbackHandler (org.sagacity.sqltoy.callback.DataSourceCallbackHandler)19 List (java.util.List)16 DataAccessException (org.sagacity.sqltoy.exception.DataAccessException)16 QueryExecutorExtend (org.sagacity.sqltoy.model.inner.QueryExecutorExtend)15 SqlToyResult (org.sagacity.sqltoy.config.model.SqlToyResult)12 BaseException (org.sagacity.sqltoy.exception.BaseException)10 NoSqlConfigModel (org.sagacity.sqltoy.config.model.NoSqlConfigModel)5 DataSource (javax.sql.DataSource)4 Test (org.junit.jupiter.api.Test)4 ParallQueryExecutor (org.sagacity.sqltoy.dialect.executor.ParallQueryExecutor)4 QueryExecutor (org.sagacity.sqltoy.executor.QueryExecutor)4 InputStream (java.io.InputStream)3 Document (org.w3c.dom.Document)3