From 67594983fd944ad9a34dff5b18996b011e55cbb6 Mon Sep 17 00:00:00 2001 From: "Takahashi.Hiroyuki" Date: Tue, 21 Apr 2026 19:04:50 +0900 Subject: [PATCH 1/4] =?UTF-8?q?OrderBy=E3=81=A7=E5=BC=8F=E3=82=92=E6=8C=87?= =?UTF-8?q?=E5=AE=9A=E3=81=97=E3=81=9F=E5=A0=B4=E5=90=88=E3=81=AE=E3=82=A8?= =?UTF-8?q?=E3=83=A9=E3=83=BC=E8=A7=A3=E6=B6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generic/search/SearchContextBase.java | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java index 5584f7ff42..40e726db19 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java @@ -59,6 +59,7 @@ import org.iplass.mtp.entity.query.SortSpec.NullOrderingSpec; import org.iplass.mtp.entity.query.SortSpec.SortType; import org.iplass.mtp.entity.query.condition.Condition; +import org.iplass.mtp.entity.query.value.ValueExpression; import org.iplass.mtp.entity.query.value.primary.EntityField; import org.iplass.mtp.entity.query.value.primary.Literal; import org.iplass.mtp.impl.parser.ParseContext; @@ -190,20 +191,20 @@ public Select getSelect() { } } } + List fieldSelection = select.stream() + .map(EntityField::new) + .toList(); + List orderBySelection = Optional.ofNullable(getOrderBy()) + .stream() + .flatMap(orderBy -> orderBy.getSortSpecList() + .stream() + .map(SortSpec::getSortKey)) + .toList(); + // ソート条件のデータを取得カラムにしておかないと、DistinctでSQLエラーになる。 - OrderBy orderBy = getOrderBy(); - if (orderBy != null) { - for (SortSpec sortSpec : orderBy.getSortSpecList()) { - String sortKey = sortSpec.getSortKey() - .toString(); - if (!select.contains(sortKey)) - addSearchProperty(select, sortKey); - } - } - boolean distinct = getConditionSection().isDistinct(); - Select s = new Select().add(select.toArray()); - s.setDistinct(distinct); - return s; + return new Select(getConditionSection().isDistinct(), Stream.concat(fieldSelection.stream(), orderBySelection.stream()) + .distinct() + .toList()); } @Override From e200b84e6a52b3b7b023a9ccf518be49969b3996 Mon Sep 17 00:00:00 2001 From: "Takahashi.Hiroyuki" Date: Tue, 21 Apr 2026 19:04:51 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[refactor]=20=E4=B8=8D=E8=A6=81=E3=81=AAove?= =?UTF-8?q?rride=E5=89=8A=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gem/command/generic/search/SearchContextBase.java | 4 ++-- .../gem/command/generic/search/SearchSelectListContext.java | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java index 40e726db19..c5b285c8c8 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java @@ -693,11 +693,11 @@ protected Integer getOffset() { * @param propName セットするプロパティ名 * @param nest 参照先Entityのプロパティ */ - protected void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { + private void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { addSearchProperty(select, propName, null, nest); } - protected void addSearchProperty(ArrayList select, String propName, PropertyEditor editor, NestProperty... nest) { + private void addSearchProperty(ArrayList select, String propName, PropertyEditor editor, NestProperty... nest) { PropertyDefinition pd = getPropertyDefinition(propName); if (pd instanceof ReferenceProperty) { if (!select.contains(propName + "." + Entity.NAME)) { diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java index d81b2bfc61..c12dce4250 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java @@ -44,7 +44,6 @@ import org.iplass.mtp.view.generic.SearchQueryContext; import org.iplass.mtp.view.generic.SearchQueryInterrupter; import org.iplass.mtp.view.generic.SearchQueryInterrupter.SearchQueryType; -import org.iplass.mtp.view.generic.editor.NestProperty; import org.iplass.mtp.view.generic.element.property.PropertyColumn; import org.iplass.mtp.view.generic.element.property.PropertyItem; import org.iplass.mtp.view.generic.element.section.SearchConditionSection; @@ -208,11 +207,6 @@ protected Integer getOffset() { return context.getOffset(); } - @Override - protected void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { - context.addSearchProperty(select, propName, nest); - } - @Override protected EntityDefinition getReferenceEntityDefinition(ReferenceProperty rp) { return context.getReferenceEntityDefinition(rp); From b3af350909f193e3e5cd335112bd0644304a9849 Mon Sep 17 00:00:00 2001 From: "Takahashi.Hiroyuki" Date: Wed, 22 Apr 2026 13:18:36 +0900 Subject: [PATCH 3/4] =?UTF-8?q?Revert=20"[refactor]=20=E4=B8=8D=E8=A6=81?= =?UTF-8?q?=E3=81=AAoverride=E5=89=8A=E9=99=A4"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit e200b84e6a52b3b7b023a9ccf518be49969b3996. --- .../gem/command/generic/search/SearchContextBase.java | 4 ++-- .../gem/command/generic/search/SearchSelectListContext.java | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java index c5b285c8c8..40e726db19 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java @@ -693,11 +693,11 @@ protected Integer getOffset() { * @param propName セットするプロパティ名 * @param nest 参照先Entityのプロパティ */ - private void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { + protected void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { addSearchProperty(select, propName, null, nest); } - private void addSearchProperty(ArrayList select, String propName, PropertyEditor editor, NestProperty... nest) { + protected void addSearchProperty(ArrayList select, String propName, PropertyEditor editor, NestProperty... nest) { PropertyDefinition pd = getPropertyDefinition(propName); if (pd instanceof ReferenceProperty) { if (!select.contains(propName + "." + Entity.NAME)) { diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java index c12dce4250..d81b2bfc61 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchSelectListContext.java @@ -44,6 +44,7 @@ import org.iplass.mtp.view.generic.SearchQueryContext; import org.iplass.mtp.view.generic.SearchQueryInterrupter; import org.iplass.mtp.view.generic.SearchQueryInterrupter.SearchQueryType; +import org.iplass.mtp.view.generic.editor.NestProperty; import org.iplass.mtp.view.generic.element.property.PropertyColumn; import org.iplass.mtp.view.generic.element.property.PropertyItem; import org.iplass.mtp.view.generic.element.section.SearchConditionSection; @@ -207,6 +208,11 @@ protected Integer getOffset() { return context.getOffset(); } + @Override + protected void addSearchProperty(ArrayList select, String propName, NestProperty... nest) { + context.addSearchProperty(select, propName, nest); + } + @Override protected EntityDefinition getReferenceEntityDefinition(ReferenceProperty rp) { return context.getReferenceEntityDefinition(rp); From 7c9a16eefb95d601a3a3aab1592bf5227657dd71 Mon Sep 17 00:00:00 2001 From: "Takahashi.Hiroyuki" Date: Wed, 22 Apr 2026 13:49:33 +0900 Subject: [PATCH 4/4] =?UTF-8?q?=E3=83=AC=E3=83=93=E3=83=A5=E3=83=BC?= =?UTF-8?q?=E5=AF=BE=E5=BF=9C=EF=BC=9Adistinct=E6=99=82=E3=81=AESELECT?= =?UTF-8?q?=E5=88=97=E6=B1=BA=E5=AE=9A=E3=83=AD=E3=82=B8=E3=83=83=E3=82=AF?= =?UTF-8?q?=E3=82=92=E6=94=B9=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gem/command/generic/search/SearchContextBase.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java index 40e726db19..23696949f3 100644 --- a/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java +++ b/iplass-gem/src/main/java/org/iplass/gem/command/generic/search/SearchContextBase.java @@ -191,8 +191,8 @@ public Select getSelect() { } } } - List fieldSelection = select.stream() - .map(EntityField::new) + List fieldSelection = select.stream() + . map(EntityField::new) .toList(); List orderBySelection = Optional.ofNullable(getOrderBy()) .stream() @@ -202,7 +202,8 @@ public Select getSelect() { .toList(); // ソート条件のデータを取得カラムにしておかないと、DistinctでSQLエラーになる。 - return new Select(getConditionSection().isDistinct(), Stream.concat(fieldSelection.stream(), orderBySelection.stream()) + boolean isDistinct = getConditionSection().isDistinct(); + return new Select(isDistinct, (isDistinct ? Stream.concat(fieldSelection.stream(), orderBySelection.stream()) : fieldSelection.stream()) .distinct() .toList()); }