2018-08-04 16:04
package com.hexie.core.utils;
import com.jfinal.plugin.activerecord.Record;
import com.jfinal.plugin.activerecord.Table;
import com.jfinal.plugin.activerecord.dialect.Dialect;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* 主要解决sqlserver部分关键字问题导致的使用Model数据库操作异常
* 通过对表名和条件字段名加上[]处理
* 以下情况仍需手写SQL处理:
* 1.分页sql
* 2.SELECT order ... 请手写SQL改为 SELECT [order] ...
*
* @author WesleyOne
* @see com.jfinal.plugin.activerecord.dialect.SqlServerDialect 为OSC 网友战五渣贡献代码:http://www.oschina.net/question/2333909_234198
* @create 2018/8/4
*/
public class NewSqlServerDialect extends Dialect {
@Override
public String forTableBuilderDoBuild(String tableName) {
return "select * from [" + tableName + "] where 1 = 2";
}
@Override
public void forModelSave(Table table, Map attrs, StringBuilder sql, List