Skip to content

Commit

Permalink
fix: order by
Browse files Browse the repository at this point in the history
  • Loading branch information
hishidama committed Jul 30, 2024
1 parent 0d26c80 commit adabf2f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ protected void initialize() {
public Stream<ResultTable> selectRequiredQuantity(int factoryId, LocalDate date) {
var ps = selectRequiredQuantityCache.get();
var parameter = TgBindParameters.of(vFactoryId.bind(factoryId), vDate.bind(date));
if (BenchConst.WORKAROUND) {
if (BenchConst.WORKAROUND) { // order by
var list = executeAndGetList(ps, parameter);
list.sort(Comparator.comparing(ResultTable::getRIId));
return list.stream();
Expand All @@ -171,7 +171,7 @@ public Stream<ResultTable> selectRequiredQuantity(int factoryId, LocalDate date)
private final CachePreparedQuery<TgBindParameters, ResultTable> selectRequiredQuantityCache = new CachePreparedQuery<>() {
@Override
protected void initialize() {
if (BenchConst.WORKAROUND) {
if (BenchConst.WORKAROUND) { // between
this.sql = "select" //
+ " r_f_id," //
+ " r_manufacturing_date," //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.function.Consumer;

Expand All @@ -13,7 +12,6 @@
import com.tsurugidb.benchmark.costaccounting.db.entity.StockHistoryDateTime;
import com.tsurugidb.benchmark.costaccounting.db.iceaxe.CostBenchDbManagerIceaxe;
import com.tsurugidb.benchmark.costaccounting.db.iceaxe.domain.BenchVariable;
import com.tsurugidb.benchmark.costaccounting.util.BenchConst;
import com.tsurugidb.iceaxe.sql.parameter.TgBindParameters;
import com.tsurugidb.iceaxe.sql.parameter.TgBindVariable;
import com.tsurugidb.iceaxe.sql.parameter.TgBindVariable.TgBindVariableInteger;
Expand Down Expand Up @@ -67,24 +65,15 @@ public int[] insertBatch(Collection<StockHistory> entityList) {
public List<StockHistoryDateTime> selectGroupByDateTime() {
var ps = selectGroupByDateTimeCache.get();
var list = executeAndGetList(ps);
if (BenchConst.WORKAROUND) {
Collections.sort(list);
}
return list;
}

private final CacheQuery<StockHistoryDateTime> selectGroupByDateTimeCache = new CacheQuery<>() {
@Override
protected void initialize() {
if (BenchConst.WORKAROUND) {
this.sql = "select s_date, s_time from " + TABLE_NAME //
+ " group by s_date, s_time";
// + " order by s_date, s_time";
} else {
this.sql = "select s_date, s_time from " + TABLE_NAME //
+ " group by s_date, s_time" //
+ " order by s_date, s_time";
}
this.sql = "select s_date, s_time from " + TABLE_NAME //
+ " group by s_date, s_time" //
+ " order by s_date, s_time";
this.resultMapping = TgResultMapping.of(StockHistoryDateTime::new) //
.addDate("s_date", StockHistoryDateTime::setSDate) //
.addTime("s_time", StockHistoryDateTime::setSTime);
Expand All @@ -95,9 +84,6 @@ protected void initialize() {
public List<StockHistoryDateTime> selectDistinctDateTime() {
var ps = selectDistinctDateTimeCache.get();
var list = executeAndGetList(ps);
if (BenchConst.WORKAROUND) {
Collections.sort(list);
}
return list;
}

Expand Down

0 comments on commit adabf2f

Please sign in to comment.