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


Java DynamicSqlSource.getBoundSql方法代码示例

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


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

示例1: 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:txazo,项目名称:mybatis,代码行数:22,代码来源:DynamicSqlSourceTest.java

示例2: 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:toulezu,项目名称:play,代码行数:17,代码来源:DynamicSqlSourceTest.java

示例3: 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:txazo,项目名称:mybatis,代码行数:11,代码来源:DynamicSqlSourceTest.java

示例4: shouldTrimSETInsteadOfCOMMAForBothConditions

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入方法依赖的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:txazo,项目名称:mybatis,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例5: 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:txazo,项目名称:mybatis,代码行数:10,代码来源:DynamicSqlSourceTest.java

示例6: shouldHandleOgnlExpression

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入方法依赖的package包/类
@Test
public void shouldHandleOgnlExpression() throws Exception {
  final HashMap<String, String> parameterObject = new HashMap<String, String>() {{
    put("name", "Steve");
  }};
  final String expected = "Expression test: 3 / yes.";
  DynamicSqlSource source = createDynamicSqlSource(new TextSqlNode("Expression test: ${name.indexOf('v')} / ${name in {'Bob', 'Steve'\\} ? 'yes' : 'no'}."));
  BoundSql boundSql = source.getBoundSql(parameterObject);
  assertEquals(expected, boundSql.getSql());
}
 
开发者ID:txazo,项目名称:mybatis,代码行数:11,代码来源:DynamicSqlSourceTest.java

示例7: shouldTrimWHEREInsteadOfORForSecondCondition

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入方法依赖的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:txazo,项目名称:mybatis,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例8: 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

示例9: shouldTrimNoSetClause

import org.apache.ibatis.scripting.xmltags.DynamicSqlSource; //导入方法依赖的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:txazo,项目名称:mybatis,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例10: 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

示例11: shouldTrimWHEREANDWithLFForFirstCondition

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

示例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:txazo,项目名称:mybatis,代码行数:15,代码来源:DynamicSqlSourceTest.java

示例13: shouldTrimWHEREANDWithTABForFirstCondition

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

示例14: 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:txazo,项目名称:mybatis,代码行数:11,代码来源:DynamicSqlSourceTest.java

示例15: shouldTrimWHEREInsteadOfANDForBothConditions

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


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