Commit d3ed698b authored by yanzg's avatar yanzg

修改实例化关系

parent b96db6b2
...@@ -29,12 +29,17 @@ public class DbPrintSql { ...@@ -29,12 +29,17 @@ public class DbPrintSql {
// 进行SQL语句参数替换,后面增加一个空格,方便后续用正则表达式进行替换处理 // 进行SQL语句参数替换,后面增加一个空格,方便后续用正则表达式进行替换处理
String[] split = sql.split("\\?"); String[] split = sql.split("\\?");
// 参数位置
int pos = 0; int pos = 0;
// 循环获取参数
while (pos < split.length) { while (pos < split.length) {
// 获取位置信息
sb.append(split[pos]); sb.append(split[pos]);
// 获取位置
if (pos == split.length - 1) { if (pos == split.length - 1) {
break; break;
} }
// 获取对象
Object item = paras.length > pos ? paras[pos] : null; Object item = paras.length > pos ? paras[pos] : null;
String str = StringHelper.toString(item); String str = StringHelper.toString(item);
String strTo = str; String strTo = str;
...@@ -64,6 +69,7 @@ public class DbPrintSql { ...@@ -64,6 +69,7 @@ public class DbPrintSql {
* @param paras 参数 * @param paras 参数
*/ */
public void print(Class targetClass, String sqlName, long start, int row, String sql, Object... paras) { public void print(Class targetClass, String sqlName, long start, int row, String sql, Object... paras) {
try {
// 日志表忽略打印 // 日志表忽略打印
if (!configDb.isPrintSql()) { if (!configDb.isPrintSql()) {
return; return;
...@@ -76,5 +82,8 @@ public class DbPrintSql { ...@@ -76,5 +82,8 @@ public class DbPrintSql {
sql = getStringSql(sql, paras); sql = getStringSql(sql, paras);
// 打印SQL语句 // 打印SQL语句
Log.infoTag(DbPrintSql.class, String.format("%d row %s.%s", row, targetClass.getSimpleName(), sqlName), sql); Log.infoTag(DbPrintSql.class, String.format("%d row %s.%s", row, targetClass.getSimpleName(), sqlName), sql);
} catch (Exception ex) {
Log.error(DbPrintSql.class, ex);
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment