Skip to content

Commit 970d936

Browse files
authored
Merge pull request #826 from jeffgbutler/remove-deprecated-code
Remove deprecated code
2 parents bb60c74 + a602206 commit 970d936

File tree

25 files changed

+29
-779
lines changed

25 files changed

+29
-779
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@ This log will detail notable changes to MyBatis Dynamic SQL. Full details are av
44

55
## Release 2.0.0 - Unreleased
66

7-
The library now requires Java 17.
7+
Significant changes:
8+
9+
- The library now requires Java 17
10+
- Deprecated code from prior releases is removed
811

912
## Release 1.5.2 - June 3, 2024
1013

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ The library test cases provide several complete examples of using the library in
8080

8181
## Requirements
8282

83-
The library has no dependencies. Version 2.x requires Java 17. Version 1.8 requires Java 8.
83+
The library has no dependencies. Version 2.x requires Java 17. Version 1.x requires Java 8.

src/main/java/org/mybatis/dynamic/sql/AliasableSqlTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected AliasableSqlTable(String tableName, Supplier<T> constructor) {
3232
public T withAlias(String alias) {
3333
T newTable = constructor.get();
3434
((AliasableSqlTable<T>) newTable).tableAlias = alias;
35-
newTable.nameSupplier = nameSupplier;
35+
newTable.tableName = tableName;
3636
return newTable;
3737
}
3838

@@ -48,7 +48,7 @@ public T withName(String name) {
4848
Objects.requireNonNull(name);
4949
T newTable = constructor.get();
5050
((AliasableSqlTable<T>) newTable).tableAlias = tableAlias;
51-
newTable.nameSupplier = () -> name;
51+
newTable.tableName = name;
5252
return newTable;
5353
}
5454

src/main/java/org/mybatis/dynamic/sql/BasicColumn.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,8 @@
1717

1818
import java.util.Optional;
1919

20-
import org.mybatis.dynamic.sql.exception.DynamicSqlException;
2120
import org.mybatis.dynamic.sql.render.RenderingContext;
22-
import org.mybatis.dynamic.sql.render.TableAliasCalculator;
2321
import org.mybatis.dynamic.sql.util.FragmentAndParameters;
24-
import org.mybatis.dynamic.sql.util.Messages;
2522

2623
/**
2724
* Describes attributes of columns that are necessary for rendering if the column is not expected to
@@ -59,25 +56,7 @@ public interface BasicColumn {
5956
* @return a rendered SQL fragment and, optionally, parameters associated with the fragment
6057
* @since 1.5.1
6158
*/
62-
default FragmentAndParameters render(RenderingContext renderingContext) {
63-
// the default implementation ensures compatibility with prior releases. When the
64-
// deprecated renderWithTableAlias method is removed, this function can become purely abstract.
65-
// Also remove the method tableAliasCalculator() from RenderingContext.
66-
return FragmentAndParameters.fromFragment(renderWithTableAlias(renderingContext.tableAliasCalculator()));
67-
}
68-
69-
/**
70-
* Returns the name of the item aliased with a table name if appropriate.
71-
* For example, "a.foo". This is appropriate for where clauses and order by clauses.
72-
*
73-
* @param tableAliasCalculator the table alias calculator for the current renderer
74-
* @return the item name with the table alias applied
75-
* @deprecated Please replace this method by overriding the more general "render" method
76-
*/
77-
@Deprecated
78-
default String renderWithTableAlias(TableAliasCalculator tableAliasCalculator) {
79-
throw new DynamicSqlException(Messages.getString("ERROR.36")); //$NON-NLS-1$
80-
}
59+
FragmentAndParameters render(RenderingContext renderingContext);
8160

8261
/**
8362
* Utility method to make it easier to build column lists for methods that require an

src/main/java/org/mybatis/dynamic/sql/SqlTable.java

Lines changed: 4 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -18,93 +18,19 @@
1818
import java.sql.JDBCType;
1919
import java.util.Objects;
2020
import java.util.Optional;
21-
import java.util.function.Supplier;
2221

2322
import org.jetbrains.annotations.NotNull;
2423

2524
public class SqlTable implements TableExpression {
2625

27-
protected Supplier<String> nameSupplier;
26+
protected String tableName;
2827

2928
protected SqlTable(String tableName) {
30-
Objects.requireNonNull(tableName);
31-
32-
this.nameSupplier = () -> tableName;
33-
}
34-
35-
/**
36-
* Creates an SqlTable whose name can be changed at runtime.
37-
*
38-
* @param tableNameSupplier table name supplier
39-
* @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime
40-
*/
41-
@Deprecated
42-
protected SqlTable(Supplier<String> tableNameSupplier) {
43-
Objects.requireNonNull(tableNameSupplier);
44-
45-
this.nameSupplier = tableNameSupplier;
46-
}
47-
48-
/**
49-
* Creates an SqlTable whose name can be changed at runtime.
50-
*
51-
* @param schemaSupplier schema supplier
52-
* @param tableName table name
53-
* @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime
54-
*/
55-
@Deprecated
56-
protected SqlTable(Supplier<Optional<String>> schemaSupplier, String tableName) {
57-
this(Optional::empty, schemaSupplier, tableName);
58-
}
59-
60-
/**
61-
* Creates an SqlTable whose name can be changed at runtime.
62-
*
63-
* @param catalogSupplier catalog supplier
64-
* @param schemaSupplier schema supplier
65-
* @param tableName table name
66-
* @deprecated please use {@link AliasableSqlTable} if you need to change the table name at runtime
67-
*/
68-
@Deprecated
69-
protected SqlTable(Supplier<Optional<String>> catalogSupplier, Supplier<Optional<String>> schemaSupplier,
70-
String tableName) {
71-
Objects.requireNonNull(catalogSupplier);
72-
Objects.requireNonNull(schemaSupplier);
73-
Objects.requireNonNull(tableName);
74-
75-
this.nameSupplier = () -> compose(catalogSupplier, schemaSupplier, tableName);
76-
}
77-
78-
private String compose(Supplier<Optional<String>> catalogSupplier, Supplier<Optional<String>> schemaSupplier,
79-
String tableName) {
80-
return catalogSupplier.get().map(c -> compose(c, schemaSupplier, tableName))
81-
.orElseGet(() -> compose(schemaSupplier, tableName));
82-
}
83-
84-
private String compose(String catalog, Supplier<Optional<String>> schemaSupplier, String tableName) {
85-
return schemaSupplier.get().map(s -> composeCatalogSchemaAndTable(catalog, s, tableName))
86-
.orElseGet(() -> composeCatalogAndTable(catalog, tableName));
87-
}
88-
89-
private String compose(Supplier<Optional<String>> schemaSupplier, String tableName) {
90-
return schemaSupplier.get().map(s -> composeSchemaAndTable(s, tableName))
91-
.orElse(tableName);
92-
}
93-
94-
private String composeCatalogAndTable(String catalog, String tableName) {
95-
return catalog + ".." + tableName; //$NON-NLS-1$
96-
}
97-
98-
private String composeSchemaAndTable(String schema, String tableName) {
99-
return schema + "." + tableName; //$NON-NLS-1$
100-
}
101-
102-
private String composeCatalogSchemaAndTable(String catalog, String schema, String tableName) {
103-
return catalog + "." + schema + "." + tableName; //$NON-NLS-1$ //$NON-NLS-2$
29+
this.tableName = Objects.requireNonNull(tableName);
10430
}
10531

106-
public String tableNameAtRuntime() {
107-
return nameSupplier.get();
32+
public String tableName() {
33+
return tableName;
10834
}
10935

11036
public BasicColumn allColumns() {

src/main/java/org/mybatis/dynamic/sql/exception/DuplicateTableAliasException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ public DuplicateTableAliasException(SqlTable table, String newAlias, String exis
4343
}
4444

4545
private static String generateMessage(SqlTable table, String newAlias, String existingAlias) {
46-
return Messages.getString("ERROR.1", table.tableNameAtRuntime(), newAlias, existingAlias); //$NON-NLS-1$
46+
return Messages.getString("ERROR.1", table.tableName(), newAlias, existingAlias); //$NON-NLS-1$
4747
}
4848
}

src/main/java/org/mybatis/dynamic/sql/insert/render/DefaultInsertStatementProvider.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,11 @@
2121

2222
public class DefaultInsertStatementProvider<T> implements InsertStatementProvider<T> {
2323
private final String insertStatement;
24-
// need to keep both row and record for now so we don't break
25-
// old code. The MyBatis reflection utilities don't handle
26-
// the case where the attribute name is different from the getter.
27-
//
28-
// MyBatis Generator version 1.4.1 (March 8, 2022) changed to use "row" instead of "record".
29-
// Target March 2023 for removing "record" from MyBatis Dynamic SQL.
30-
private final T record;
3124
private final T row;
3225

3326
private DefaultInsertStatementProvider(Builder<T> builder) {
3427
insertStatement = Objects.requireNonNull(builder.insertStatement);
3528
row = Objects.requireNonNull(builder.row);
36-
record = row;
37-
}
38-
39-
@Override
40-
public T getRecord() {
41-
return record;
4229
}
4330

4431
@Override

src/main/java/org/mybatis/dynamic/sql/insert/render/InsertRenderingUtilities.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,6 @@ public static String calculateInsertStatement(SqlTable table, FieldAndValueColle
3131
}
3232

3333
public static String calculateInsertStatementStart(SqlTable table) {
34-
return "insert into " + table.tableNameAtRuntime(); //$NON-NLS-1$
34+
return "insert into " + table.tableName(); //$NON-NLS-1$
3535
}
3636
}

src/main/java/org/mybatis/dynamic/sql/insert/render/InsertStatementProvider.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,6 @@
1818
import org.jetbrains.annotations.NotNull;
1919

2020
public interface InsertStatementProvider<T> {
21-
/**
22-
* Return the row associated with this insert statement.
23-
*
24-
* @return the row associated with this insert statement.
25-
*
26-
* @deprecated in favor of {@link InsertStatementProvider#getRow()}
27-
*/
28-
@Deprecated
29-
T getRecord();
30-
3121
/**
3222
* Return the row associated with this insert statement.
3323
*

src/main/java/org/mybatis/dynamic/sql/render/GuaranteedTableAliasCalculator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public Optional<String> aliasForColumn(SqlTable table) {
3838
if (alias.isPresent()) {
3939
return alias;
4040
} else {
41-
return Optional.of(table.tableNameAtRuntime());
41+
return Optional.of(table.tableName());
4242
}
4343
}
4444

0 commit comments

Comments
 (0)