|
@@ -35,7 +35,7 @@ import org.apache.ibatis.logging.Log;
|
|
|
import org.apache.ibatis.logging.LogFactory;
|
|
|
import org.apache.ibatis.reflection.MetaObject;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
|
|
@@ -49,7 +49,7 @@ import java.util.Optional;
|
|
|
@NoArgsConstructor
|
|
|
@AllArgsConstructor
|
|
|
public class JsqlParserCountOptimize implements ISqlParser {
|
|
|
- private static final List<SelectItem> COUNT_SELECT_ITEM = countSelectItem();
|
|
|
+ private static final List<SelectItem> COUNT_SELECT_ITEM = Collections.singletonList(defaultCountSelectItem());
|
|
|
private final Log logger = LogFactory.getLog(JsqlParserCountOptimize.class);
|
|
|
|
|
|
private boolean optimizeJoin = false;
|
|
@@ -57,19 +57,12 @@ public class JsqlParserCountOptimize implements ISqlParser {
|
|
|
/**
|
|
|
* 获取jsqlparser中count的SelectItem
|
|
|
*/
|
|
|
- private static List<SelectItem> countSelectItem() {
|
|
|
+ private static SelectItem defaultCountSelectItem() {
|
|
|
Function function = new Function();
|
|
|
+ ExpressionList expressionList = new ExpressionList(Collections.singletonList(new LongValue(1)));
|
|
|
function.setName("COUNT");
|
|
|
- List<Expression> expressions = new ArrayList<>();
|
|
|
- LongValue longValue = new LongValue(1);
|
|
|
- ExpressionList expressionList = new ExpressionList();
|
|
|
- expressions.add(longValue);
|
|
|
- expressionList.setExpressions(expressions);
|
|
|
function.setParameters(expressionList);
|
|
|
- List<SelectItem> selectItems = new ArrayList<>();
|
|
|
- SelectExpressionItem selectExpressionItem = new SelectExpressionItem(function);
|
|
|
- selectItems.add(selectExpressionItem);
|
|
|
- return selectItems;
|
|
|
+ return new SelectExpressionItem(function);
|
|
|
}
|
|
|
|
|
|
@Override
|