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

Java WhereSqlNode类代码示例

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

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



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

示例1: select

import org.apache.ibatis.scripting.xmltags.WhereSqlNode; //导入依赖的package包/类
/**
 * 查询(dr = 0)
 *
 * @param ms
 * @return SqlNode
 */
private SqlNode select(MappedStatement ms, Class<?> entityClass) {

    List<SqlNode> sqlNodes = new LinkedList<SqlNode>();
    //静态的sql部分:select column ... from table
    sqlNodes.add(new StaticTextSqlNode("SELECT "
            + EntityHelper.getSelectColumns(entityClass)
            + " FROM "
            + tableName(entityClass)));
    //将if添加到<where>
    sqlNodes.add(new WhereSqlNode(ms.getConfiguration(), new StaticTextSqlNode(" dr = 0")));
    String orderByClause = EntityHelper.getOrderByClause(entityClass);
    if (orderByClause.length() > 0) {
        sqlNodes.add(new StaticTextSqlNode("ORDER BY " + orderByClause));
    }
    return new MixedSqlNode(sqlNodes);
}
 
开发者ID:mazhaoyong,项目名称:api-server-seed,代码行数:23,代码来源:CommonSelectMapperProvider.java


示例2: shouldTrimWHEREInsteadOfANDForFirstCondition

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


示例3: shouldTrimWHEREANDWithLFForFirstCondition

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


示例4: shouldTrimWHEREANDWithCRLFForFirstCondition

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


示例5: shouldTrimWHEREANDWithTABForFirstCondition

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


示例6: shouldTrimWHEREORWithLFForFirstCondition

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


示例7: shouldTrimWHEREORWithCRLFForFirstCondition

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


示例8: shouldTrimWHEREORWithTABForFirstCondition

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


示例9: shouldTrimWHEREInsteadOfORForSecondCondition

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


示例10: shouldTrimWHEREInsteadOfANDForBothConditions

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


示例11: shouldTrimNoWhereClause

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


示例12: selectByIdList

import org.apache.ibatis.scripting.xmltags.WhereSqlNode; //导入依赖的package包/类
public SqlNode selectByIdList(MappedStatement ms) {
    Class<?> entityClass = getEntityClass(ms);
    //修改返回值类型为实体类型
    setResultType(ms, entityClass);
    List<SqlNode> sqlNodes = new LinkedList<SqlNode>();
    //静态的sql部分:select column ... from table
    sqlNodes.add(new StaticTextSqlNode("SELECT "
            + EntityHelper.getSelectColumns(entityClass)
            + " FROM "
            + tableName(entityClass)));

    List<SqlNode> whereNodes = new LinkedList<SqlNode>();

    whereNodes.add(new StaticTextSqlNode(" dr = 0 "));

    ForEachSqlNode forEachSqlNode = new ForEachSqlNode(ms.getConfiguration(),
            new StaticTextSqlNode("#{item}"), "list", "index", "item", " and id in (", ")", ",");
    whereNodes.add(forEachSqlNode);

    sqlNodes.add(new WhereSqlNode(ms.getConfiguration(), new MixedSqlNode(whereNodes)));

    String orderByClause = EntityHelper.getOrderByClause(entityClass);
    if (orderByClause.length() > 0) {
        sqlNodes.add(new StaticTextSqlNode("ORDER BY " + orderByClause));
    }

    return new MixedSqlNode(sqlNodes);
}
 
开发者ID:mazhaoyong,项目名称:api-server-seed,代码行数:29,代码来源:CommonSelectMapperProvider.java


示例13: batchDelete

import org.apache.ibatis.scripting.xmltags.WhereSqlNode; //导入依赖的package包/类
public SqlNode batchDelete(MappedStatement ms) {
	// 获取实体类型
	Class<?> entityClass = getEntityClass(ms);
	LOG.debug("要更新的实体类:"+entityClass.getName());
	List<SqlNode> sqlNodes = new LinkedList<>();
	// update table
	sqlNodes.add(new StaticTextSqlNode("UPDATE " + tableName(entityClass)));
	// 获取全部列
	Set<EntityColumn> columnList = EntityHelper.getColumns(entityClass);
	EntityColumn drCol = null;
	EntityColumn idCol = null;
	for (EntityColumn entityColumn : columnList) {
		if (DBConsts.FIELD_DR.equalsIgnoreCase(entityColumn.getColumn())) {
			drCol = entityColumn;
		}
		if (entityColumn.isId()) {
			idCol = entityColumn;
		}
	}

	sqlNodes.add(new SetSqlNode(ms.getConfiguration(), new StaticTextSqlNode(drCol.getColumn() + " = 1 ")));

	ForEachSqlNode forEachSqlNode = new ForEachSqlNode(ms.getConfiguration(),
			new StaticTextSqlNode("#{item." + idCol.getProperty() + "}"), "list", "index", "item", " id in (", ")",
			",");

	sqlNodes.add(new WhereSqlNode(ms.getConfiguration(), forEachSqlNode));

	return new MixedSqlNode(sqlNodes);
}
 
开发者ID:mazhaoyong,项目名称:api-server-seed,代码行数:31,代码来源:BatchLogicDeleteMapperProvider.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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