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

Java IfSqlNode类代码示例

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

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



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

示例1: getInsertFileds

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


示例2: getUpdateColumns

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


示例3: shouldConditionallyIncludeWhere

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


示例4: shouldConditionallyExcludeWhere

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


示例5: shouldConditionallyDefault

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


示例6: shouldConditionallyChooseFirst

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


示例7: shouldConditionallyChooseSecond

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


示例8: shouldTrimWHEREInsteadOfANDForFirstCondition

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


示例9: shouldTrimWHEREANDWithLFForFirstCondition

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


示例10: shouldTrimWHEREANDWithCRLFForFirstCondition

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


示例11: shouldTrimWHEREANDWithTABForFirstCondition

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


示例12: shouldTrimWHEREORWithLFForFirstCondition

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


示例13: shouldTrimWHEREORWithCRLFForFirstCondition

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


示例14: shouldTrimWHEREORWithTABForFirstCondition

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


示例15: shouldTrimWHEREInsteadOfORForSecondCondition

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


示例16: shouldTrimWHEREInsteadOfANDForBothConditions

import org.apache.ibatis.scripting.xmltags.IfSqlNode; //导入依赖的package包/类
@Test
public void shouldTrimWHEREInsteadOfANDForBothConditions() throws Exception {
  final String expected = "SELECT * FROM BLOG WHERE  ID = ?   OR NAME = ?";
  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 = ?  ")), "true"
          )
      )));
  BoundSql boundSql = source.getBoundSql(null);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:yuexiahandao,项目名称:MybatisCode,代码行数:15,代码来源:DynamicSqlSourceTest.java


示例17: shouldTrimNoWhereClause

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


示例18: shouldTrimSETInsteadOfCOMMAForBothConditions

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


示例19: shouldTrimNoSetClause

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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java RenderWither类代码示例发布时间:2022-05-22
下一篇:
Java RouteContext类代码示例发布时间: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