本文整理汇总了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;未经允许,请勿转载。 |
请发表评论