rename "toDebugSQL()" method name to "toSQL()"

This commit is contained in:
开源海哥 2023-06-01 18:32:51 +08:00
parent 2ac702a140
commit 5fc08dbeb2
4 changed files with 12 additions and 12 deletions

View File

@ -68,7 +68,7 @@ public class AccountServiceImpl extends CacheableServiceImpl<AccountMapper, Acco
// 根据方法名加查询 SQL 语句缓存结果数据
// 加上方法名是为了避免不同的方法使用一样的 QueryWrapper
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public List<Account> list(QueryWrapper query) {
return super.list(query);
}
@ -122,25 +122,25 @@ public class AccountServiceImpl extends CacheableServiceImpl<MyAccountMapper, Ac
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public Account getOne(QueryWrapper query) {
return super.getOne(query);
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public <R> R getOneAs(QueryWrapper query, Class<R> asType) {
return super.getOneAs(query, asType);
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public List<Account> list(QueryWrapper query) {
return super.list(query);
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public <R> List<R> listAs(QueryWrapper query, Class<R> asType) {
return super.listAs(query, asType);
}
@ -153,13 +153,13 @@ public class AccountServiceImpl extends CacheableServiceImpl<MyAccountMapper, Ac
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public long count(QueryWrapper query) {
return super.count(query);
}
@Override
@Cacheable(key = "#root.methodName + ':' + #query.toDebugSQL()")
@Cacheable(key = "#root.methodName + ':' + #query.toSQL()")
public Page<Account> page(Page<Account> page, QueryWrapper query) {
return super.page(page, query);
}

View File

@ -535,7 +535,7 @@ public class QueryWrapper extends BaseQueryWrapper<QueryWrapper> {
}
public String toDebugSQL() {
public String toSQL() {
String sql = DialectFactory.getDialect().forSelectByQuery(this);
return SqlUtil.replaceSqlParams(sql, getValueArray());
}

View File

@ -60,7 +60,7 @@ public class AccountSqlTester {
});
TableManager.setDynamicTableProcessor(original -> original+"_01");
System.out.println(query.toDebugSQL());
System.out.println(query.toSQL());
}
@ -75,7 +75,7 @@ public class AccountSqlTester {
TableManager.setDynamicTableProcessor(original -> original+"_01");
TableManager.setDynamicTableProcessor(original -> original+"_01");
System.out.println(query.toDebugSQL());
System.out.println(query.toSQL());
}

View File

@ -36,7 +36,7 @@ import java.util.Collection;
* 方法避免缓存无法更新造成数据不一致
* <li>重写{@link #updateBatch(Collection, int)} 方法默认抛出异常不支持批量更新操作
* 防止批量更新数据缓存不一致
* <li>重写 {@link #query()} 方法解决使用 {@link QueryWrapper#toDebugSQL()} 作为缓存
* <li>重写 {@link #query()} 方法解决使用 {@link QueryWrapper#toSQL()} 作为缓存
* 的主键时"SELECT * FROM" 后面没有表名的问题
* </ul>
*
@ -84,7 +84,7 @@ public class CacheableServiceImpl<M extends BaseMapper<T>, T> implements IServic
*
* <p>使用 {@link QueryWrapper#create()} 构建默认查询条件的时候
* 要使用 {@link QueryWrapper#from(String...)} 方法指定从哪个表
* 查询数据不然使用 {@link QueryWrapper#toDebugSQL()} 生成的
* 查询数据不然使用 {@link QueryWrapper#toSQL()} 生成的
* SQL 语句就是 {@code "SELECT * FROM"}没有表名信息
*
* <p>默认通过反射获取表名建议重写根据情况设置默认表名以提升效率