List of usage examples for org.apache.ibatis.jdbc SqlBuilder DELETE_FROM
public static void DELETE_FROM(String table)
From source file:com.yunmel.syncretic.core.BaseMapperProvider.java
License:Apache License
public SqlNode deleteByIDS(MappedStatement ms) { Class<?> entityClass = getEntityClass(ms); Set<EntityColumn> entityColumns = EntityHelper.getPKColumns(entityClass); EntityColumn entityColumn = null;/*from w w w . j a v a 2 s.co m*/ Iterator<EntityColumn> it = entityColumns.iterator(); if (it.hasNext()) { entityColumn = it.next(); } EntityColumn column = entityColumn; List<SqlNode> sqlNodes = new ArrayList<SqlNode>(); SqlBuilder.BEGIN(); SqlBuilder.DELETE_FROM(tableName(entityClass)); String sql = SqlBuilder.SQL(); sqlNodes.add(new StaticTextSqlNode(sql + " WHERE " + column.getColumn() + " IN ")); SqlNode foreach = new ForEachSqlNode(ms.getConfiguration(), new StaticTextSqlNode("#{" + column.getProperty() + "}"), "ids", "index", column.getProperty(), "(", ")", ","); sqlNodes.add(foreach); return new MixedSqlNode(sqlNodes); }