移动数据库文件位置

master
星期八 5 years ago
parent a350a5a742
commit baacdea833
  1. 113
      panda-jdbc/src/main/java/org/panda/jdbc/sql/AbstractDbBuiler.java
  2. 2
      panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/DbBuilerFactory.java
  3. 6
      panda-jdbc/src/main/java/org/panda/jdbc/sql/factory/impl/DefaultDbBuilerFactory.java

@ -1,113 +0,0 @@
package org.panda.jdbc.sql;
import org.panda.jdbc.mode.Table;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @author qi
* 抽象类-sql构造器
* 实现的子类有: MysqlBuilder OragleBuilder 为应对不同数据库特点有部分方法抽象由子类实现
* Created by qi_liang on 2018/6/2.
*/
public abstract class AbstractDbBuiler {
/**
* 构建更新表结构sql
* @param classSet 实体类集合
* @param tableList 数据库已存在表集合
* @return
*/
abstract public String automaticUpdateDb(Set<Class> classSet, List<Table> tableList);
/**
*  构建分页sql语句
* @param sql
* @param pageInterface
* @return
*/
abstract public String concatPageSql(String sql, PageInterface pageInterface);
/**
* 构建创建表的sql语句
* @param clazz 对象的class
* @return 构建好的创建表的sql(类型:String)
*/
abstract public String createTableStr(Class clazz);
/**
* 构建新增sql语句
* @param obj
* @return
*/
abstract public String insertSql(Object obj);
/**
* 构建新增sql语句
* @param obj
* @param fieldMap
* @return
*/
abstract public String insertSql(Object obj, Map<String,Object> fieldMap);
/**
* 构建更新sql语句
* @param obj
* @return
*/
abstract public String updateSql(Object obj);
/**
* 构建更新sql语句
* @param obj
* @param fieldMap
* @return
*/
abstract public String updateSql(Object obj, Map<String,Object> fieldMap);
/**
* 构建删除sql
* @param obj
* @return
*/
abstract public String deleteSql(Object obj);
/**
* 构建删除sql
* @param obj
* @param fieldMap
* @return
*/
abstract public String deleteSql(Object obj,Map<String,Object> fieldMap);
/**
* 构建统计sql语句
* @param sql
* @return
*/
public String countSql(String sql){
StringBuffer sb=new StringBuffer("SELECT COUNT(*) FROM ");
//SQL 转成大写适
String upperCaseSql = sql.toUpperCase();
//统计SQL排除排序SQL代码
if (sql.lastIndexOf(SqlConstant.ORDER_SQL)>sql.lastIndexOf(")")){
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length(),upperCaseSql.lastIndexOf(SqlConstant.ORDER_SQL)));
}else{
sb.append(sql.substring(upperCaseSql.indexOf(SqlConstant.FROM_SQL)+SqlConstant.FROM_SQL.length()));
}
return sb.toString();
}
}

@ -1,7 +1,7 @@
package org.panda.jdbc.sql.factory;
import org.panda.jdbc.sql.AbstractDbBuiler;
import org.panda.jdbc.sql.builder.AbstractDbBuiler;
/**
* Sql 构造器工厂

@ -1,9 +1,9 @@
package org.panda.jdbc.sql.factory.impl;
import org.panda.jdbc.sql.AbstractDbBuiler;
import org.panda.jdbc.sql.MysqlBuilder;
import org.panda.jdbc.sql.OracleBuiler;
import org.panda.jdbc.sql.builder.AbstractDbBuiler;
import org.panda.jdbc.sql.builder.MysqlBuilder;
import org.panda.jdbc.sql.builder.OracleBuiler;
import org.panda.jdbc.sql.SqlConstant;
import org.panda.jdbc.sql.factory.DbBuilerFactory;

Loading…
Cancel
Save