List of usage examples for org.apache.ibatis.scripting.xmltags ForEachSqlNode ForEachSqlNode
public ForEachSqlNode(Configuration configuration, SqlNode contents, String collectionExpression, String index,
String item, String open, String close, String separator)
From source file:cn.org.awcp.core.mybatis.mapper.MapperTemplate.java
License:Open Source License
/** * create criteria from baseExample/* w w w.ja va2s . c o m*/ * * @param sqlNodes * @param baseExample */ protected SqlNode createCriteria(MappedStatement ms) { List<SqlNode> ifSqlNodes = new ArrayList<SqlNode>(); SqlNode noValueSqlNode = new TextSqlNode(" ${criterion.condition} "); ifSqlNodes.add(new IfSqlNode(noValueSqlNode, "criterion.noValue")); SqlNode singleValueSqlNode = new TextSqlNode(" ${criterion.condition} #{criterion.value} "); ifSqlNodes.add(new IfSqlNode(singleValueSqlNode, "criterion.singleValue")); SqlNode betweenValueSqlNode = new TextSqlNode( " ${criterion.condition} #{criterion.value} and #{criterion.secondValue} "); ifSqlNodes.add(new IfSqlNode(betweenValueSqlNode, "criterion.betweenValue")); List<SqlNode> listSqlNode = new ArrayList<SqlNode>(); listSqlNode.add(new TextSqlNode(" ${criterion.condition} ")); SqlNode listItemNode = new TextSqlNode(" #{listItem} "); SqlNode foreachSqlNode3 = new ForEachSqlNode(ms.getConfiguration(), listItemNode, "criterion.value", null, "listItem", " (", ") ", ","); listSqlNode.add(foreachSqlNode3); ifSqlNodes.add(new IfSqlNode(new MixedSqlNode(listSqlNode), "criterion.listValue")); SqlNode chooseSqlNode = new ChooseSqlNode(ifSqlNodes, null); SqlNode foreachSqlNode2 = new ForEachSqlNode(ms.getConfiguration(), chooseSqlNode, "criteria.criteria", null, "criterion", null, null, "AND"); SqlNode trimSqlNode = new TrimSqlNode(ms.getConfiguration(), foreachSqlNode2, " (", "AND", ") ", (String) null); SqlNode iftestSqlNode = new IfSqlNode(trimSqlNode, "criteria.valid"); SqlNode foreachSqlNode1 = new ForEachSqlNode(ms.getConfiguration(), iftestSqlNode, "oredCriteria", null, "criteria", null, null, "OR"); return foreachSqlNode1; }
From source file:com.github.abel533.mapperhelper.MapperTemplate.java
License:Open Source License
public IfSqlNode ExampleValidSqlNode(Configuration configuration) { List<SqlNode> whenSqlNodes = new ArrayList<SqlNode>(); IfSqlNode noValueSqlNode = new IfSqlNode(new TextSqlNode("and ${criterion.condition}"), "criterion.noValue"); whenSqlNodes.add(noValueSqlNode);/* w w w. j av a 2s. c om*/ IfSqlNode singleValueSqlNode = new IfSqlNode( new TextSqlNode("and ${criterion.condition} #{criterion.value}"), "criterion.singleValue"); whenSqlNodes.add(singleValueSqlNode); IfSqlNode betweenValueSqlNode = new IfSqlNode( new TextSqlNode("and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}"), "criterion.betweenValue"); whenSqlNodes.add(betweenValueSqlNode); List<SqlNode> listValueContentSqlNodes = new ArrayList<SqlNode>(); listValueContentSqlNodes.add(new TextSqlNode("and ${criterion.condition}")); ForEachSqlNode listValueForEachSqlNode = new ForEachSqlNode(configuration, new StaticTextSqlNode("#{listItem}"), "criterion.value", null, "listItem", "(", ")", ","); listValueContentSqlNodes.add(listValueForEachSqlNode); IfSqlNode listValueSqlNode = new IfSqlNode(new MixedSqlNode(listValueContentSqlNodes), "criterion.listValue"); whenSqlNodes.add(listValueSqlNode); ChooseSqlNode chooseSqlNode = new ChooseSqlNode(whenSqlNodes, null); ForEachSqlNode criteriaSqlNode = new ForEachSqlNode(configuration, chooseSqlNode, "criteria.criteria", null, "criterion", null, null, null); TrimSqlNode trimSqlNode = new TrimSqlNode(configuration, criteriaSqlNode, "(", "and", ")", null); IfSqlNode validSqlNode = new IfSqlNode(trimSqlNode, "criteria.valid"); return validSqlNode; }
From source file:com.github.abel533.mapperhelper.MapperTemplate.java
License:Open Source License
/** * Examplewhere/*from w ww. jav a 2s . c o m*/ * * @param configuration * @return */ public WhereSqlNode exampleWhereClause(Configuration configuration) { ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, ExampleValidSqlNode(configuration), "oredCriteria", null, "criteria", null, null, " or "); WhereSqlNode whereSqlNode = new WhereSqlNode(configuration, forEachSqlNode); return whereSqlNode; }
From source file:com.github.abel533.mapperhelper.MapperTemplate.java
License:Open Source License
/** * Example-Updatewhere// w ww . ja v a2 s. c om * * @param configuration * @return */ public WhereSqlNode updateByExampleWhereClause(Configuration configuration) { //?"example.oredCriteria" ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, ExampleValidSqlNode(configuration), "example.oredCriteria", null, "criteria", null, null, " or "); WhereSqlNode whereSqlNode = new WhereSqlNode(configuration, forEachSqlNode); return whereSqlNode; }
From source file:com.hand.hap.mybatis.mapperhelper.MapperTemplate.java
License:Open Source License
@Deprecated public IfSqlNode ExampleValidSqlNode(Configuration configuration) { List<SqlNode> whenSqlNodes = new ArrayList<SqlNode>(); IfSqlNode noValueSqlNode = new IfSqlNode(new TextSqlNode(" and ${criterion.condition}"), "criterion.noValue"); whenSqlNodes.add(noValueSqlNode);//from w w w.ja v a 2 s . c o m IfSqlNode singleValueSqlNode = new IfSqlNode( new TextSqlNode(" and ${criterion.condition} #{criterion.value}"), "criterion.singleValue"); whenSqlNodes.add(singleValueSqlNode); IfSqlNode betweenValueSqlNode = new IfSqlNode( new TextSqlNode(" and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}"), "criterion.betweenValue"); whenSqlNodes.add(betweenValueSqlNode); List<SqlNode> listValueContentSqlNodes = new ArrayList<SqlNode>(); listValueContentSqlNodes.add(new TextSqlNode(" and ${criterion.condition}")); ForEachSqlNode listValueForEachSqlNode = new ForEachSqlNode(configuration, new StaticTextSqlNode("#{listItem}"), "criterion.value", null, "listItem", "(", ")", ","); listValueContentSqlNodes.add(listValueForEachSqlNode); IfSqlNode listValueSqlNode = new IfSqlNode(new MixedSqlNode(listValueContentSqlNodes), "criterion.listValue"); whenSqlNodes.add(listValueSqlNode); ChooseSqlNode chooseSqlNode = new ChooseSqlNode(whenSqlNodes, null); ForEachSqlNode criteriaSqlNode = new ForEachSqlNode(configuration, chooseSqlNode, "criteria.criteria", null, "criterion", null, null, null); TrimSqlNode trimSqlNode = new TrimSqlNode(configuration, criteriaSqlNode, "(", "and", ")", null); IfSqlNode validSqlNode = new IfSqlNode(trimSqlNode, "criteria.valid"); return validSqlNode; }
From source file:com.hand.hap.mybatis.mapperhelper.MapperTemplate.java
License:Open Source License
/** * Examplewhere/* www.ja va 2 s . c om*/ * * @param configuration * @return * @deprecated 4.x */ @Deprecated public WhereSqlNode exampleWhereClause(Configuration configuration) { ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, ExampleValidSqlNode(configuration), "oredCriteria", null, "criteria", null, null, " or "); WhereSqlNode whereSqlNode = new WhereSqlNode(configuration, forEachSqlNode); return whereSqlNode; }
From source file:com.hand.hap.mybatis.mapperhelper.MapperTemplate.java
License:Open Source License
/** * Example-Updatewhere//from ww w . j a v a 2 s . c om * * @param configuration * @return * @deprecated 4.x */ @Deprecated public WhereSqlNode updateByExampleWhereClause(Configuration configuration) { //?"example.oredCriteria" ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, ExampleValidSqlNode(configuration), "example.oredCriteria", null, "criteria", null, null, " or "); WhereSqlNode whereSqlNode = new WhereSqlNode(configuration, forEachSqlNode); return whereSqlNode; }
From source file:com.sxj.mybatis.orm.builder.GenericStatementBuilder.java
License:Open Source License
private SqlNode getMultiGetFields(String collection) { TextSqlNode fieldSqlNode = new TextSqlNode("#{" + ITEM + "}"); ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, fieldSqlNode, collection, "index", ITEM, "(", ")", ","); return forEachSqlNode; }
From source file:com.sxj.mybatis.orm.builder.GenericStatementBuilder.java
License:Open Source License
private SqlNode getBatchDeleteFields(String collection) { TextSqlNode fieldSqlNode = new TextSqlNode("#{" + ITEM + "}"); ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, fieldSqlNode, collection, "index", ITEM, "(", ")", ","); return forEachSqlNode; }
From source file:com.sxj.mybatis.orm.builder.GenericStatementBuilder.java
License:Open Source License
private SqlNode getBatchInsertFields(String collection) { List<SqlNode> contents = new ArrayList<SqlNode>(); for (Field field : columnFields) { List<SqlNode> sqlNodes = new ArrayList<SqlNode>(); Column column = field.getAnnotation(Column.class); if (Date.class.isAssignableFrom(field.getType()) && column != null && column.sysdate() == true) { sqlNodes.add(new TextSqlNode("now(),")); } else {/*from www . j a va 2s . com*/ sqlNodes.add(new TextSqlNode("#{item." + field.getName() + "},")); } contents.add(new MixedSqlNode(sqlNodes)); } TrimSqlNode fieldSqlNode = new TrimSqlNode(configuration, new MixedSqlNode(contents), " (", null, ")", ","); ForEachSqlNode forEachSqlNode = new ForEachSqlNode(configuration, fieldSqlNode, collection, "index", ITEM, "", "", ","); return new TrimSqlNode(configuration, forEachSqlNode, " VALUES ", null, "", ","); }