当前位置: 首页>>代码示例>>Java>>正文


Java DynamicSqlSource类代码示例

本文整理汇总了Java中org.apache.ibatis.scripting.xmltags.DynamicSqlSource的典型用法代码示例。如果您正苦于以下问题:Java DynamicSqlSource类的具体用法?Java DynamicSqlSource怎么用?Java DynamicSqlSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DynamicSqlSource类属于org.apache.ibatis.scripting.xmltags包,在下文中一共展示了DynamicSqlSource类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldIterateOnceForEachItemInCollection

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldIterateOnceForEachItemInCollection() throws Exception {
  final HashMap<String, String[]> parameterObject = new HashMap<String, String[]>() {{
    put("array", new String[]{"one", "two", "three"});
  }};
  final String expected = "SELECT * FROM BLOG WHERE ID in (  one = ? AND two = ? AND three = ? )";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG WHERE ID in"),
      new ForEachSqlNode(new Configuration(),mixedContents(new TextSqlNode("${item} = #{item}")), "array", "index", "item", "(", ")", "AND"));
  BoundSql boundSql = source.getBoundSql(parameterObject);
  assertEquals(expected, boundSql.getSql());
  assertEquals(3, boundSql.getParameterMappings().size());
  assertEquals("__frch_item_0", boundSql.getParameterMappings().get(0).getProperty());
  assertEquals("__frch_item_1", boundSql.getParameterMappings().get(1).getProperty());
  assertEquals("__frch_item_2", boundSql.getParameterMappings().get(2).getProperty());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:17,代码来源:DynamicSqlSourceTest.java

示例2: shouldPerformStrictMatchOnForEachVariableSubstitution

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldPerformStrictMatchOnForEachVariableSubstitution() throws Exception {
  final Map<String, Object> param = new HashMap<String, Object>();
  final Map<String, String> uuu = new HashMap<String, String>();
  uuu.put("u", "xyz");
  List<Bean> uuuu = new ArrayList<Bean>();
  uuuu.add(new Bean("bean id"));
  param.put("uuu", uuu);
  param.put("uuuu", uuuu);
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("INSERT INTO BLOG (ID, NAME, NOTE, COMMENT) VALUES"),
      new ForEachSqlNode(new Configuration(),mixedContents(
          new TextSqlNode("#{uuu.u}, #{u.id}, #{ u,typeHandler=org.apache.ibatis.type.StringTypeHandler},"
              + " #{u:VARCHAR,typeHandler=org.apache.ibatis.type.StringTypeHandler}")), "uuuu", "uu", "u", "(", ")", ","));
  BoundSql boundSql = source.getBoundSql(param);
  assertEquals(4, boundSql.getParameterMappings().size());
  assertEquals("uuu.u", boundSql.getParameterMappings().get(0).getProperty());
  assertEquals("__frch_u_0.id", boundSql.getParameterMappings().get(1).getProperty());
  assertEquals("__frch_u_0", boundSql.getParameterMappings().get(2).getProperty());
  assertEquals("__frch_u_0", boundSql.getParameterMappings().get(3).getProperty());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:22,代码来源:DynamicSqlSourceTest.java

示例3: processMappedStatement

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
/**
 * 修改SqlSource
 *
 * @param ms
 * @throws Throwable
 */
public void processMappedStatement(MappedStatement ms) throws Throwable {
    SqlSource sqlSource = ms.getSqlSource();
    MetaObject msObject = SystemMetaObject.forObject(ms);
    SqlSource pageSqlSource;
    if (sqlSource instanceof StaticSqlSource) {
        pageSqlSource = new PageStaticSqlSource((StaticSqlSource) sqlSource);
    } else if (sqlSource instanceof RawSqlSource) {
        pageSqlSource = new PageRawSqlSource((RawSqlSource) sqlSource);
    } else if (sqlSource instanceof ProviderSqlSource) {
        pageSqlSource = new PageProviderSqlSource((ProviderSqlSource) sqlSource);
    } else if (sqlSource instanceof DynamicSqlSource) {
        pageSqlSource = new PageDynamicSqlSource((DynamicSqlSource) sqlSource);
    } else {
        throw new RuntimeException("无法处理该类型[" + sqlSource.getClass() + "]的SqlSource");
    }
    msObject.setValue("sqlSource", pageSqlSource);
    //由于count查询需要修改返回值,因此这里要创建一个Count查询的MS
    msCountMap.put(ms.getId(), MSUtils.newCountMappedStatement(ms));
}
 
开发者ID:xushaomin,项目名称:apple-orm,代码行数:26,代码来源:SqlUtil.java

示例4: buildDelete

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
private void buildDelete(String statementId){
	Integer timeout = null;
	Class<?> parameterType = entityClass;
	
	//~~~~~~~~~~~~~~~~~~~~~~~
	boolean flushCache = true;
	boolean useCache = false;
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	SqlNode sqlNode = new TextSqlNode("DELETE FROM " + tableName + " WHERE " + getIdColumnName() + " = #{" + getIdFieldName() + "} " + getVersionSQL());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, sqlNode);
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.DELETE, null, timeout, null, parameterType, null, null, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:19,代码来源:GenericStatementBuilder.java

示例5: buildUpdate

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
private void buildUpdate(String statementId){
	Integer timeout = null;
	Class<?> parameterType = entityClass;
	
	//~~~~~~~~~~~~~
	boolean flushCache = true;
	boolean useCache = false;
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	List<SqlNode> contents = new ArrayList<SqlNode>();
	contents.add(this.getUpdateSql());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, new MixedSqlNode(contents));
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.UPDATE, null, timeout, null, parameterType, null, null, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:20,代码来源:GenericStatementBuilder.java

示例6: buildSelect

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
private void buildSelect(String statementId){
	Integer fetchSize  = null;
	Integer timeout = entity.timeout() == -1 ? null : entity.timeout();
	Class<?> resultType = entityClass;
	
	//~~~~~~~~~~~~~~~~~
	boolean flushCache = entity.flushCache();
	boolean useCache = entity.useCache();
	boolean resultOrdered = false;
	KeyGenerator keyGenerator = new NoKeyGenerator();
	
	List<SqlNode> contents = new ArrayList<SqlNode>();
	contents.add(this.getGetSql());
	
	SqlSource sqlSource = new DynamicSqlSource(configuration, new MixedSqlNode(contents));
	
	assistant.addMappedStatement(statementId, sqlSource, StatementType.PREPARED,
			SqlCommandType.SELECT, fetchSize, timeout, null, null, null, resultType, null,
			flushCache, useCache, resultOrdered, keyGenerator, null, null, databaseId, lang);
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:21,代码来源:GenericStatementBuilder.java

示例7: selectUnionAll

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
public String selectUnionAll(Class<?> entityType, String condition, String orderBy, LockMode lockMode) {
	String statementId = this.buildStatementId(entityType, "[email protected]" + condition + "|" + orderBy);
	if (configuration.hasStatement(statementId)) {
		return statementId;
	}
	ResultMap resultMap = resultMapBuilder.getDefault(entityType);
	SqlNode rootSqlNode = new SqlBuilder(entityType).selectUnionAll(configuration, condition, orderBy, lockMode);
	DynamicSqlSource sqlSource = new DynamicSqlSource(configuration, rootSqlNode);
	MappedStatement statement = new MappedStatement.Builder(configuration, statementId, sqlSource,
			SqlCommandType.SELECT).resultMaps(Arrays.asList(resultMap)).build();
	StatementResultMapHelper.addMappedStatement(configuration, statement);
	return statementId;
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:14,代码来源:MappedStatementBuilder.java

示例8: shouldDemonstrateSimpleExpectedTextWithNoLoopsOrConditionals

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldDemonstrateSimpleExpectedTextWithNoLoopsOrConditionals() throws Exception {
  final String expected = "SELECT * FROM BLOG";
  final MixedSqlNode sqlNode = mixedContents(new TextSqlNode(expected));
  DynamicSqlSource source = createDynamicSqlSource(sqlNode);
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:9,代码来源:DynamicSqlSourceTest.java

示例9: shouldDemonstrateMultipartExpectedTextWithNoLoopsOrConditionals

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldDemonstrateMultipartExpectedTextWithNoLoopsOrConditionals() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE ID = ?";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new TextSqlNode("WHERE ID = ?"));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:10,代码来源:DynamicSqlSourceTest.java

示例10: shouldConditionallyIncludeWhere

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldConditionallyIncludeWhere() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE ID = ?";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new IfSqlNode(mixedContents(new TextSqlNode("WHERE ID = ?")), "true"
      ));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:11,代码来源:DynamicSqlSourceTest.java

示例11: shouldConditionallyExcludeWhere

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldConditionallyExcludeWhere() throws Exception {
  final String expected = "SELECT * FROM BLOG";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new IfSqlNode(mixedContents(new TextSqlNode("WHERE ID = ?")), "false"
      ));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:11,代码来源:DynamicSqlSourceTest.java

示例12: shouldConditionallyDefault

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldConditionallyDefault() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE CATEGORY = 'DEFAULT'";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new ChooseSqlNode(new ArrayList<SqlNode>() {{
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = ?")), "false"
        ));
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = 'NONE'")), "false"
        ));
      }}, mixedContents(new TextSqlNode("WHERE CATEGORY = 'DEFAULT'"))));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例13: shouldConditionallyChooseFirst

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldConditionallyChooseFirst() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE CATEGORY = ?";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new ChooseSqlNode(new ArrayList<SqlNode>() {{
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = ?")), "true"
        ));
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = 'NONE'")), "false"
        ));
      }}, mixedContents(new TextSqlNode("WHERE CATEGORY = 'DEFAULT'"))));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例14: shouldConditionallyChooseSecond

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldConditionallyChooseSecond() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE CATEGORY = 'NONE'";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new ChooseSqlNode(new ArrayList<SqlNode>() {{
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = ?")), "false"
        ));
        add(new IfSqlNode(mixedContents(new TextSqlNode("WHERE CATEGORY = 'NONE'")), "true"
        ));
      }}, mixedContents(new TextSqlNode("WHERE CATEGORY = 'DEFAULT'"))));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例15: shouldTrimWHEREInsteadOfANDForFirstCondition

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入依赖的package包/类
@Test
public void shouldTrimWHEREInsteadOfANDForFirstCondition() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE  ID = ?";
  DynamicSqlSource source = createDynamicSqlSource(
      new TextSqlNode("SELECT * FROM BLOG"),
      new WhereSqlNode(new Configuration(),mixedContents(
          new IfSqlNode(mixedContents(new TextSqlNode("   and ID = ?  ")), "true"
          ),
          new IfSqlNode(mixedContents(new TextSqlNode("   or NAME = ?  ")), "false"
          )
      )));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:DynamicSqlSourceTest.java


注:本文中的org.apache.ibatis.scripting.xmltags.DynamicSqlSource类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。