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 243c060

Browse files
committed
Deprecate JdbcMySqlDialect.INSTANCE and MySqlDialect.MYSQL_IDENTIFIER_PROCESSING.
MySql does not have a fixed Identifierprocessing, therefore predefined instances doesn't make sense. Closes #2060 See https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html
1 parent d411be4 commit 243c060

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,17 @@
4242
*/
4343
public class JdbcMySqlDialect extends MySqlDialect implements JdbcDialect {
4444

45-
public static final JdbcMySqlDialect INSTANCE = new JdbcMySqlDialect();
45+
/**
46+
* Predefined instance of the {@literal JdbcMySqlDialect}.
47+
*
48+
* @deprecated Use the constructor instead. There is no one correct MySqlDialect, since the behaviour of MySql depends
49+
* on various configuration options. See
50+
*
51+
* <pre>
52+
* <a href="https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html">Identifier Case Sensitivity</a>
53+
* </pre>
54+
*/
55+
@Deprecated(forRemoval = true, since = "4.0") public static final JdbcMySqlDialect INSTANCE = new JdbcMySqlDialect();
4656

4757
public JdbcMySqlDialect(IdentifierProcessing identifierProcessing) {
4858
super(identifierProcessing);

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import org.springframework.data.relational.core.mapping.RelationalMappingContext;
3636
import org.springframework.data.relational.core.mapping.Sequence;
3737
import org.springframework.data.relational.core.mapping.Table;
38+
import org.springframework.data.relational.core.sql.IdentifierProcessing;
3839
import org.springframework.jdbc.core.RowMapper;
3940
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
4041
import org.springframework.jdbc.core.namedparam.SqlParameterSource;
@@ -50,6 +51,8 @@ class IdGeneratingEntityCallbackTest {
5051

5152
@Mock NamedParameterJdbcOperations operations;
5253
RelationalMappingContext relationalMappingContext;
54+
private JdbcMySqlDialect mySqlDialect = new JdbcMySqlDialect(
55+
IdentifierProcessing.create(new IdentifierProcessing.Quoting("`"), IdentifierProcessing.LetterCasing.LOWER_CASE));
5356

5457
@BeforeEach
5558
void setUp() {
@@ -64,8 +67,8 @@ void sequenceGenerationIsNotSupported() {
6467

6568
NamedParameterJdbcOperations operations = mock(NamedParameterJdbcOperations.class);
6669

67-
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,
68-
JdbcMySqlDialect.INSTANCE, operations);
70+
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,mySqlDialect,
71+
operations);
6972

7073
EntityWithSequence processed = (EntityWithSequence) subject.onBeforeSave(new EntityWithSequence(),
7174
MutableAggregateChange.forSave(new EntityWithSequence()));
@@ -76,8 +79,8 @@ void sequenceGenerationIsNotSupported() {
7679
@Test // GH-1923
7780
void entityIsNotMarkedWithTargetSequence() {
7881

79-
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,
80-
JdbcMySqlDialect.INSTANCE, operations);
82+
IdGeneratingEntityCallback subject = new IdGeneratingEntityCallback(relationalMappingContext,mySqlDialect,
83+
operations);
8184

8285
NoSequenceEntity processed = (NoSequenceEntity) subject.onBeforeSave(new NoSequenceEntity(),
8386
MutableAggregateChange.forSave(new NoSequenceEntity()));

‎spring-data-relational/src/main/java/org/springframework/data/relational/core/dialect/MySqlDialect.java‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,26 @@ public class MySqlDialect extends AbstractDialect {
3737

3838
/**
3939
* MySQL defaults for {@link IdentifierProcessing}.
40+
*
41+
* @deprecated Construct your own {@link IdentifierProcessing}. There is no one standard identifier processing for
42+
* MySql.See
43+
*
44+
* <pre>
45+
* <a href=
46+
"https://dev.mysql.com/doc/refman/8.4/en/identifier-case-sensitivity.html">Identifier Case Sensitivity</a>
47+
* </pre>
4048
*/
41-
public static final IdentifierProcessing MYSQL_IDENTIFIER_PROCESSING = IdentifierProcessing.create(new Quoting("`"),
42-
LetterCasing.LOWER_CASE);
49+
@Deprecated(forRemoval = true,
50+
since = "4.0") public static final IdentifierProcessing MYSQL_IDENTIFIER_PROCESSING = IdentifierProcessing
51+
.create(new Quoting("`"), LetterCasing.LOWER_CASE);
4352

4453
/**
4554
* Singleton instance.
4655
*
4756
* @deprecated use either the {@code org.springframework.data.r2dbc.dialect.MySqlDialect} or
48-
* {@code org.springframework.data.jdbc.core.dialect.JdbcMySqlDialect}
57+
* {@code org.springframework.data.jdbc.core.dialect.JdbcMySqlDialect}
4958
*/
50-
@Deprecated(forRemoval = true)
51-
public static final MySqlDialect INSTANCE = new MySqlDialect();
59+
@Deprecated(forRemoval = true) public static final MySqlDialect INSTANCE = new MySqlDialect();
5260

5361
private final IdentifierProcessing identifierProcessing;
5462

0 commit comments

Comments
(0)

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