diff --git a/sqli-builder/src/main/java/io/xream/sqli/builder/internal/DefaultQ2Sql.java b/sqli-builder/src/main/java/io/xream/sqli/builder/internal/DefaultQ2Sql.java index eec6ca2..44eccc9 100644 --- a/sqli-builder/src/main/java/io/xream/sqli/builder/internal/DefaultQ2Sql.java +++ b/sqli-builder/src/main/java/io/xream/sqli/builder/internal/DefaultQ2Sql.java @@ -295,7 +295,7 @@ private void sqlArr0(boolean isSub, boolean isTotalRowsIgnored, SqlBuilt sqlBuil for (SqlBuilt sub : subsAndValueBinding.getSubList()) { int start = sb.sbSource.indexOf(SqlScript.SUB); sb.sbSource.replace(start, start + SqlScript.SUB.length(), - SqlScript.LEFT_PARENTTHESIS + sub.getSql().toString() + SqlScript.RIGHT_PARENTTHESIS + SqlScript.LEFT_PARENTTHESIS + sub.getSb().toString() + SqlScript.RIGHT_PARENTTHESIS ); } @@ -310,7 +310,7 @@ private void sqlArr0(boolean isSub, boolean isTotalRowsIgnored, SqlBuilt sqlBuil StringBuilder sqlSb = new StringBuilder(); sqlSb.append(sb.sbResult).append(sb.sbSource).append(sb.sbCondition); - sqlBuilt.setSql(sqlSb); + sqlBuilt.setSb(sqlSb); } private void sqlArr1(boolean isSub, boolean isTotalRowsIgnored, SqlBuilt sqlBuilt, SqlSubsAndValueBinding subsAndValueBinding, SqlSth sb) { @@ -323,7 +323,7 @@ private void sqlArr1(boolean isSub, boolean isTotalRowsIgnored, SqlBuilt sqlBuil for (SqlBuilt sub : subsAndValueBinding.getSubList()) { int start = sqlSb.indexOf(SqlScript.SUB); sqlSb.replace(start, start + SqlScript.SUB.length(), - SqlScript.LEFT_PARENTTHESIS + sub.getSql().toString() + SqlScript.RIGHT_PARENTTHESIS + SqlScript.LEFT_PARENTTHESIS + sub.getSb().toString() + SqlScript.RIGHT_PARENTTHESIS ); } @@ -341,14 +341,14 @@ private void sqlArr1(boolean isSub, boolean isTotalRowsIgnored, SqlBuilt sqlBuil int start = sqlSb.indexOf(SqlScript.WITH_PLACE); sqlSb.replace(start, start + SqlScript.WITH_PLACE.length(),sb.sbResult.toString()).append(sb.sbCondition); - sqlBuilt.setSql(sqlSb); + sqlBuilt.setSb(sqlSb); return; } StringBuilder sqlSb = new StringBuilder(); sqlSb.append(sb.with).append(sb.sbResult).append(sb.sbSource).append(sb.sbCondition); - sqlBuilt.setSql(sqlSb); + sqlBuilt.setSb(sqlSb); } diff --git a/sqli-builder/src/main/java/io/xream/sqli/builder/internal/SqlBuilt.java b/sqli-builder/src/main/java/io/xream/sqli/builder/internal/SqlBuilt.java index e058cbc..d44c941 100644 --- a/sqli-builder/src/main/java/io/xream/sqli/builder/internal/SqlBuilt.java +++ b/sqli-builder/src/main/java/io/xream/sqli/builder/internal/SqlBuilt.java @@ -24,7 +24,7 @@ public final class SqlBuilt { private String countSql; - private StringBuilder sql; + private StringBuilder sb; private boolean isWith; public String getCountSql() { @@ -35,12 +35,12 @@ public void setCountSql(String countSql) { this.countSql = countSql; } - public StringBuilder getSql() { - return sql; + public StringBuilder getSb() { + return sb; } - public void setSql(StringBuilder sql) { - this.sql = sql; + public void setSb(StringBuilder sb) { + this.sb = sb; } public boolean isWith() { diff --git a/sqli-builder/src/main/java/io/xream/sqli/test/SqlGenerator.java b/sqli-builder/src/main/java/io/xream/sqli/test/SqlGenerator.java index 92ad022..08cc044 100644 --- a/sqli-builder/src/main/java/io/xream/sqli/test/SqlGenerator.java +++ b/sqli-builder/src/main/java/io/xream/sqli/test/SqlGenerator.java @@ -90,7 +90,7 @@ public List getSubList() { sb.append("-- Test trace: " + kv.getK()).append("\r\n"); sb.append("-- Test value: " + valueList).append("\r\n"); - sb.append(sqlBuilt.getSql()).append(";").append("\r\n"); + sb.append(sqlBuilt.getSb()).append(";").append("\r\n"); sb.append("-- -------------------------------------------").append("\r\n").append("\r\n"); } diff --git a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/DaoImpl.java b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/DaoImpl.java index 9dae519..39a0af3 100644 --- a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/DaoImpl.java +++ b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/DaoImpl.java @@ -217,7 +217,7 @@ public List list(Q q) { Class clz = q.getClzz(); List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, q, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(clz, sql); List list = this.jdbcHelper.queryForList(sql, valueList, Parser.get(clz), this.dialect); @@ -231,7 +231,7 @@ public Page find(Q q) { Class clz = q.getClzz(); List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, q, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(clz, sql); @@ -331,7 +331,7 @@ public Page> find(Q.X xq) { List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, xq, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); Class clz = xq.getClzz(); SqliLoggerProxy.debug(xq.getRepositoryClzz(), sql); @@ -348,7 +348,7 @@ public List> list(Q.X xq) { List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, xq, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(xq.getRepositoryClzz(), sql); @@ -361,7 +361,7 @@ public List> list(Q.X xq) { public List listPlainValue(Class clzz, Q.X xq){ List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, xq, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(xq.getRepositoryClzz(), sql); @@ -374,7 +374,7 @@ public T getOne(Q q) { Class clz = q.getClzz(); List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, q, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(clz, sql); List list = this.jdbcHelper.queryForList(sql, valueList, Parser.get(clz), this.dialect); @@ -391,7 +391,7 @@ public void findToHandle(Q.X xq, RowHandler> handler) { List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, xq, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); SqliLoggerProxy.debug(xq.getRepositoryClzz(), sql); @@ -403,7 +403,7 @@ public void findToHandle(Q q, RowHandler handler) { List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, q, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); Class clz = q.getClzz(); SqliLoggerProxy.debug(clz, sql); @@ -417,7 +417,7 @@ public boolean exists(Q q) { Class clz = q.getClzz(); List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList, q, q2Sql, dialect); - String sql = sqlBuilt.getSql().toString(); + String sql = sqlBuilt.getSb().toString(); sql = sql.replace("*","1"); sql += " LIMIT 1"; SqliLoggerProxy.debug(clz, sql); diff --git a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/SqlBuilder.java b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/SqlBuilder.java index f87a18c..5054b03 100644 --- a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/SqlBuilder.java +++ b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/SqlBuilder.java @@ -126,9 +126,9 @@ public List getSubList() { } }); - StringBuilder sqlBuilder = sqlBuilt.getSql(); + StringBuilder sb = sqlBuilt.getSb(); if (SqliStringUtil.isNotNull(q.getLastSqlSegment())) { - sqlBuilder.append(SPACE).append(q.getLastSqlSegment()); + sb.append(SPACE).append(q.getLastSqlSegment()); } int page = q.getPage(); @@ -137,11 +137,11 @@ public List getSubList() { int start = (page - 1) * rows; long last = q.getLast(); - sqlBuilder = dialect.buildPageSql(sqlBuilder, start, rows,last); + sb = dialect.buildPageSql(sb, start, rows,last); // StringBuilder sb = new StringBuilder(); // sb.append(sql); - sqlBuilt.setSql(sqlBuilder); + sqlBuilt.setSb(sb); ObjectDataConverter.log(q, valueList); return sqlBuilt; diff --git a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/TemporaryDaoImpl.java b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/TemporaryDaoImpl.java index 890464d..dc79e49 100644 --- a/sqli-repo/src/main/java/io/xream/sqli/repository/dao/TemporaryDaoImpl.java +++ b/sqli-repo/src/main/java/io/xream/sqli/repository/dao/TemporaryDaoImpl.java @@ -78,7 +78,7 @@ public boolean findToCreate(Class clzz, Q.X xq) { List valueList = new ArrayList<>(); SqlBuilt sqlBuilt = sqlBuilder.buildQueryByQ(valueList,xq, q2Sql, dialect); - StringBuilder fromSqlSb = sqlBuilt.getSql(); + StringBuilder fromSqlSb = sqlBuilt.getSb(); Parsed parsed = Parser.get(clzz);