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

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

Introduction

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

Prototype

public static void BEGIN() 

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;/* 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);
}