Skip to content

Commit 8ef46d8

Browse files
committed
Introduced intermediate class
1 parent 31df742 commit 8ef46d8

File tree

3 files changed

+44
-19
lines changed

3 files changed

+44
-19
lines changed

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/InlineQuery.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,14 @@
2929
* @author Jens Schauder
3030
* @since 2.3
3131
*/
32-
public class InlineQuery extends AbstractSegment implements TableLike {
32+
public class InlineQuery extends Subselect implements TableLike {
3333

34-
private final Select select;
3534
private final SqlIdentifier alias;
3635

3736
InlineQuery(Select select, SqlIdentifier alias) {
3837

3938
super(select);
4039

41-
this.select = select;
4240
this.alias = alias;
4341
}
4442

@@ -81,10 +79,4 @@ public SqlIdentifier getName() {
8179
public SqlIdentifier getReferenceName() {
8280
return alias;
8381
}
84-
85-
@Override
86-
public String toString() {
87-
return "(" + select + ") AS " + alias;
88-
}
89-
9082
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.relational.core.sql;
17+
18+
/**
19+
* Baseclass for all kinds of "select in parenthesis".
20+
*
21+
* @since 3.1
22+
* @author Mark Paluch
23+
* @author Jens Schauder
24+
*/
25+
public abstract class Subselect extends AbstractSegment {
26+
27+
private final Select select;
28+
29+
protected Subselect(Select select) {
30+
this.select = select;
31+
}
32+
33+
public Select getSelect() {
34+
return select;
35+
}
36+
37+
@Override
38+
public String toString() {
39+
return "(" + select + ")";
40+
}
41+
42+
}

spring-data-relational/src/main/java/org/springframework/data/relational/core/sql/SubselectExpression.java

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,10 @@
2121
* @author Jens Schauder
2222
* @since 1.1
2323
*/
24-
public class SubselectExpression extends AbstractSegment implements Expression {
25-
26-
private final Select subselect;
24+
public class SubselectExpression extends Subselect implements Expression {
2725

2826
SubselectExpression(Select subselect) {
2927

3028
super(subselect);
31-
32-
this.subselect = subselect;
33-
}
34-
35-
@Override
36-
public String toString() {
37-
return "(" + subselect + ")";
3829
}
3930
}

0 commit comments

Comments
 (0)