Example usage for org.apache.ibatis.jdbc SqlBuilder sql

List of usage examples for org.apache.ibatis.jdbc SqlBuilder sql

Introduction

In this page you can find the example usage for org.apache.ibatis.jdbc SqlBuilder sql.

Prototype

private static SQL sql() 

Source Link

Usage

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 .ja  v  a  2  s  .  c om
    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);
}