• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java TextSqlNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: selectUnionAll

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的package包/类
public SqlNode selectUnionAll(Configuration configuration, String conditions, String orderBy, LockMode lockMode) {
	String sql = select(conditions, orderBy).toString();
	StringBuffer sqlSb = new StringBuffer();
	Matcher matcher = ARGUMENT_REGEX.matcher(sql);
	while (matcher.find()) {
		String name = matcher.group(1);
		matcher.appendReplacement(sqlSb, "#{item." + name + "}");
	}
	matcher.appendTail(sqlSb);
	if (lockMode == LockMode.UPGRADE) {
		sqlSb.append(" FOR UPDATE");
	} else if (lockMode == LockMode.UPGRADE_NOWAIT) {
		sqlSb.append(" FOR UPDATE NOWAIT");
	}
	SqlNode contents = new TextSqlNode(sqlSb.toString());
	String collectionExpression = "list";
	String index = "index";
	String item = "item";
	String open = "";
	String close = "";
	String separator = " UNION ALL ";
	return new ForEachSqlNode(configuration, contents, collectionExpression, index, item, open, close, separator);
}
 
开发者ID:yaoakeji,项目名称:hibatis,代码行数:24,代码来源:SqlBuilder.java


示例2: shouldIterateOnceForEachItemInCollection

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例3: shouldPerformStrictMatchOnForEachVariableSubstitution

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例4: getInsertFileds

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的package包/类
private SqlNode getInsertFileds() {
	List<SqlNode> contents = new ArrayList<SqlNode>();
	for(Field field : columnFields){
		List<SqlNode> sqlNodes = new ArrayList<SqlNode>();

		if(Date.class.isAssignableFrom(field.getType()) 
				&& field.getAnnotation(Column.class) != null 
				&& field.getAnnotation(Column.class).sysdate() == true){
			sqlNodes.add(new TextSqlNode("now(),"));
		} else {
			sqlNodes.add(new TextSqlNode("#{" + field.getName() + "},"));
		}
		
		contents.add(new IfSqlNode(new MixedSqlNode(sqlNodes), getTestByField(field)));
	}
	
	return new TrimSqlNode(configuration, new MixedSqlNode(contents), " VALUES (", null, ")", ",");
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:19,代码来源:GenericStatementBuilder.java


示例5: buildDelete

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例6: getUpdateColumns

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的package包/类
private SqlNode getUpdateColumns(){
	List<SqlNode> contents = new ArrayList<SqlNode>();
	for(Field field : columnFields){
		List<SqlNode> sqlNodes = new ArrayList<SqlNode>();
		
		if(Date.class.isAssignableFrom(field.getType()) 
				&& field.getAnnotation(Column.class) != null 
				&& field.getAnnotation(Column.class).sysdate() == true){
			sqlNodes.add(new TextSqlNode(getColumnNameByField(field) + " = now(),"));
		} else {
			sqlNodes.add(new TextSqlNode(getColumnNameByField(field) + " = #{" + field.getName() + "},"));
		}
		
		contents.add(new IfSqlNode(new MixedSqlNode(sqlNodes), getTestByField(field)));
	}
	
	return new SetSqlNode(configuration, new MixedSqlNode(contents));
}
 
开发者ID:makersoft,项目名称:mybatis-activesql,代码行数:19,代码来源:GenericStatementBuilder.java


示例7: shouldDemonstrateSimpleExpectedTextWithNoLoopsOrConditionals

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例8: shouldDemonstrateMultipartExpectedTextWithNoLoopsOrConditionals

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例9: shouldConditionallyIncludeWhere

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例10: shouldConditionallyExcludeWhere

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例11: shouldConditionallyDefault

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例12: shouldConditionallyChooseFirst

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例13: shouldConditionallyChooseSecond

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例14: shouldTrimWHEREInsteadOfANDForFirstCondition

import org.apache.ibatis.scripting.xmltags.TextSqlNode; //导入依赖的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


示例15: shouldTrimWHEREANDWithLFForFirstCondition

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


示例16: shouldTrimWHEREANDWithCRLFForFirstCondition

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


示例17: shouldTrimWHEREANDWithTABForFirstCondition

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


示例18: shouldTrimWHEREORWithLFForFirstCondition

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


示例19: shouldTrimWHEREORWithCRLFForFirstCondition

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


示例20: shouldTrimWHEREORWithTABForFirstCondition

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BlocksActivity类代码示例发布时间:2022-05-22
下一篇:
Java TypeDefinition类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap