com.dt.jdbc.parser.DeleteParser Maven / Gradle / Ivy
The newest version!
package com.dt.jdbc.parser;
import com.dt.core.data.ParseData;
import com.dt.core.engine.WhereEngine;
import java.util.ArrayList;
import java.util.List;
/**
* 删除解析器
*
* @author 白超
* @version 1.0
* @since 2018/7/10
*/
public class DeleteParser {
public String deleteByPrimaryKey(String tableName, String primaryKeyName) {
return "delete from " + tableName + " where " + primaryKeyName + " = ?";
}
public String batchDeleteByPrimaryKeys(String tableName, String primaryKeyName, int recordSize) {
StringBuilder sql = new StringBuilder(32);
sql.append("delete from ").append(tableName).append(" where ").append(primaryKeyName).append(" in (");
for (; recordSize > 0; recordSize--) {
if (recordSize == 1) {
sql.append("?");
} else {
sql.append("?,");
}
}
return sql.append(")").toString();
}
public ParseData delete(WhereEngine whereEngine) {
ParseData parseData;
String tableName = whereEngine.getTableName();
String tableAlias = whereEngine.getTableAlias();
StringBuilder sql = new StringBuilder(64);
List