Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5ffed08

Browse files
committed
GH-2031 Introduced new JDBC dialect counterparts
1 parent 1f2e694 commit 5ffed08

29 files changed

+263
-80
lines changed

‎spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/dialect/JdbcDb2Dialect.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* @author Christoph Strobl
3434
* @since 2.3
3535
*/
36-
public class JdbcDb2Dialect extends Db2Dialect {
36+
public class JdbcDb2Dialect extends Db2Dialect implementsJdbcDialect{
3737

3838
public static JdbcDb2Dialect INSTANCE = new JdbcDb2Dialect();
3939

‎spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/dialect/JdbcDialect.java‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
* {@link org.springframework.data.relational.core.dialect.ArrayColumns} that offer JDBC specific functionality.
2323
*
2424
* @author Jens Schauder
25+
* @author Mikhail Polivakha
2526
* @since 2.3
2627
*/
2728
public interface JdbcDialect extends Dialect {
@@ -33,6 +34,7 @@ public interface JdbcDialect extends Dialect {
3334
* @return the JDBC specific array support object that describes how array-typed columns are supported by this
3435
* dialect.
3536
*/
36-
@Override
37-
JdbcArrayColumns getArraySupport();
37+
default JdbcArrayColumns getArraySupport() {
38+
return JdbcArrayColumns.Unsupported.INSTANCE;
39+
}
3840
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 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+
17+
package org.springframework.data.jdbc.core.dialect;
18+
19+
import org.springframework.data.relational.core.dialect.H2Dialect;
20+
21+
/**
22+
* JDBC specific H2 Dialect.
23+
*
24+
* @author Mikhail Polivakha
25+
*/
26+
public class JdbcH2Dialect extends H2Dialect implements JdbcDialect {
27+
28+
public static JdbcH2Dialect INSTANCE = new JdbcH2Dialect();
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 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+
17+
package org.springframework.data.jdbc.core.dialect;
18+
19+
import org.springframework.data.relational.core.dialect.HsqlDbDialect;
20+
21+
/**
22+
* JDBC specific HsqlDB Dialect.
23+
*
24+
* @author Mikhail Polivakha
25+
*/
26+
public class JdbcHsqlDbDialect extends HsqlDbDialect implements JdbcDialect {
27+
28+
public static JdbcHsqlDbDialect INSTANCE = new JdbcHsqlDbDialect();
29+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright 2025 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+
17+
package org.springframework.data.jdbc.core.dialect;
18+
19+
import org.springframework.data.relational.core.dialect.MariaDbDialect;
20+
import org.springframework.data.relational.core.sql.IdentifierProcessing;
21+
22+
/**
23+
* JDBC specific MariaDb Dialect.
24+
*
25+
* @author Mikhail Polivakha
26+
*/
27+
public class JdbcMariaDbDialect extends MariaDbDialect implements JdbcDialect {
28+
29+
public JdbcMariaDbDialect(IdentifierProcessing identifierProcessing) {
30+
super(identifierProcessing);
31+
}
32+
}

‎spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/dialect/JdbcMySqlDialect.java‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,12 @@
3838
*
3939
* @author Jens Schauder
4040
* @author Christoph Strobl
41+
* @author Mikhail Polivakha
4142
* @since 2.3
4243
*/
43-
public class JdbcMySqlDialect extends MySqlDialect {
44+
public class JdbcMySqlDialect extends MySqlDialect implements JdbcDialect {
45+
46+
public static JdbcMySqlDialect INSTANCE = new JdbcMySqlDialect();
4447

4548
public JdbcMySqlDialect(IdentifierProcessing identifierProcessing) {
4649
super(identifierProcessing);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright 2025 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+
17+
package org.springframework.data.jdbc.core.dialect;
18+
19+
import org.springframework.data.relational.core.dialect.OracleDialect;
20+
21+
/**
22+
* JDBC specific Oracle Dialect.
23+
*
24+
* @author Mikhail Polivakha
25+
*/
26+
public class JdbcOracleDialect extends OracleDialect implements JdbcDialect {
27+
28+
public static JdbcOracleDialect INSTANCE = new JdbcOracleDialect();
29+
}

‎spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/dialect/JdbcSqlServerDialect.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
* @author Mikhail Polivakha
3636
* @since 2.3
3737
*/
38-
public class JdbcSqlServerDialect extends SqlServerDialect {
38+
public class JdbcSqlServerDialect extends SqlServerDialect implementsJdbcDialect{
3939

4040
public static JdbcSqlServerDialect INSTANCE = new JdbcSqlServerDialect();
4141

‎spring-data-jdbc/src/main/java/org/springframework/data/jdbc/repository/config/DialectResolver.java‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,15 @@
2929
import org.springframework.core.io.support.SpringFactoriesLoader;
3030
import org.springframework.dao.NonTransientDataAccessException;
3131
import org.springframework.data.jdbc.core.dialect.JdbcDb2Dialect;
32+
import org.springframework.data.jdbc.core.dialect.JdbcDialect;
33+
import org.springframework.data.jdbc.core.dialect.JdbcH2Dialect;
34+
import org.springframework.data.jdbc.core.dialect.JdbcHsqlDbDialect;
35+
import org.springframework.data.jdbc.core.dialect.JdbcMariaDbDialect;
3236
import org.springframework.data.jdbc.core.dialect.JdbcMySqlDialect;
37+
import org.springframework.data.jdbc.core.dialect.JdbcOracleDialect;
3338
import org.springframework.data.jdbc.core.dialect.JdbcPostgresDialect;
3439
import org.springframework.data.jdbc.core.dialect.JdbcSqlServerDialect;
3540
import org.springframework.data.relational.core.dialect.Dialect;
36-
import org.springframework.data.relational.core.dialect.H2Dialect;
37-
import org.springframework.data.relational.core.dialect.HsqlDbDialect;
38-
import org.springframework.data.relational.core.dialect.MariaDbDialect;
39-
import org.springframework.data.relational.core.dialect.OracleDialect;
4041
import org.springframework.data.relational.core.sql.IdentifierProcessing;
4142
import org.springframework.data.util.Optionals;
4243
import org.springframework.jdbc.core.ConnectionCallback;
@@ -50,6 +51,7 @@
5051
* available {@link JdbcDialectProvider extensions}.
5152
*
5253
* @author Jens Schauder
54+
* @author Mikhail Polivakha
5355
* @since 2.0
5456
* @see Dialect
5557
* @see SpringFactoriesLoader
@@ -109,23 +111,23 @@ public Optional<Dialect> getDialect(JdbcOperations operations) {
109111
}
110112

111113
@Nullable
112-
private static Dialect getDialect(Connection connection) throws SQLException {
114+
private static JdbcDialect getDialect(Connection connection) throws SQLException {
113115

114116
DatabaseMetaData metaData = connection.getMetaData();
115117

116118
String name = metaData.getDatabaseProductName().toLowerCase(Locale.ENGLISH);
117119

118120
if (name.contains("hsql")) {
119-
return HsqlDbDialect.INSTANCE;
121+
return JdbcHsqlDbDialect.INSTANCE;
120122
}
121123
if (name.contains("h2")) {
122-
return H2Dialect.INSTANCE;
124+
return JdbcH2Dialect.INSTANCE;
123125
}
124126
if (name.contains("mysql")) {
125127
return new JdbcMySqlDialect(getIdentifierProcessing(metaData));
126128
}
127129
if (name.contains("mariadb")) {
128-
return new MariaDbDialect(getIdentifierProcessing(metaData));
130+
return new JdbcMariaDbDialect(getIdentifierProcessing(metaData));
129131
}
130132
if (name.contains("postgresql")) {
131133
return JdbcPostgresDialect.INSTANCE;
@@ -137,7 +139,7 @@ private static Dialect getDialect(Connection connection) throws SQLException {
137139
return JdbcDb2Dialect.INSTANCE;
138140
}
139141
if (name.contains("oracle")) {
140-
return OracleDialect.INSTANCE;
142+
return JdbcOracleDialect.INSTANCE;
141143
}
142144

143145
LOG.info(String.format("Couldn't determine Dialect for \"%s\"", name));

‎spring-data-jdbc/src/test/java/org/springframework/data/jdbc/core/convert/DefaultDataAccessStrategyUnitTests.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.jupiter.api.BeforeEach;
2323
import org.junit.jupiter.api.Test;
2424
import org.springframework.data.annotation.Id;
25+
import org.springframework.data.jdbc.core.dialect.JdbcHsqlDbDialect;
2526
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
2627
import org.springframework.data.relational.core.conversion.IdValueSource;
2728
import org.springframework.data.relational.core.dialect.Dialect;
@@ -58,7 +59,7 @@ class DefaultDataAccessStrategyUnitTests {
5859
void before() {
5960

6061
DelegatingDataAccessStrategy relationResolver = new DelegatingDataAccessStrategy();
61-
Dialect dialect = HsqlDbDialect.INSTANCE;
62+
Dialect dialect = JdbcHsqlDbDialect.INSTANCE;
6263
converter = new MappingJdbcConverter(context, relationResolver, new JdbcCustomConversions(),
6364
new DefaultJdbcTypeFactory(jdbcOperations));
6465
accessStrategy = new DataAccessStrategyFactory( //

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /