mirror of
https://gitee.com/mybatis-flex/mybatis-flex.git
synced 2025-12-06 16:48:24 +08:00
rename "toDebugSQL()" method name to "toSQL()"
This commit is contained in:
parent
2ac702a140
commit
5fc08dbeb2
@ -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);
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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>默认通过反射获取表名,建议重写,根据情况设置默认表名,以提升效率。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user