Skip to content

Commit de100c1

Browse files
authored
Merge pull request #76 from komamitsu/support-spring-boot-4
Support Spring Boot 4
2 parents 16f6ec8 + a17533d commit de100c1

File tree

4 files changed

+56
-7
lines changed

4 files changed

+56
-7
lines changed

.github/workflows/ci.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ jobs:
5757
strategy:
5858
matrix:
5959
java_version: [17, 21]
60+
spring_boot_version: [3, 4]
6061
steps:
6162
- uses: actions/checkout@v4
6263
- name: Set up JDK ${{ matrix.java_version }}
@@ -70,6 +71,8 @@ jobs:
7071
run: ./gradlew publishToMavenLocal
7172
- name: Setup Gradle
7273
uses: gradle/actions/setup-gradle@v4
73-
- name: Execute the example app using Spring Boot to test spring-data-sqlite
74+
- name: Execute the example app using Spring Boot ${{ matrix.spring_boot_version }} to test spring-data-sqlite
7475
working-directory: example
76+
env:
77+
EXAMPLE_APP_SPRING_BOOT_VERSION: ${{ matrix.spring_boot_version }}
7578
run: ./gradlew run

example/build.gradle

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ group 'org.komamitsu'
88
version '1.0-SNAPSHOT'
99

1010
def springDataSqliteVersion = getSpringDataSqliteVersion()
11+
def springBootVersion = System.getenv('EXAMPLE_APP_SPRING_BOOT_VERSION') ?: '4'
1112

1213
repositories {
1314
mavenCentral()
@@ -16,10 +17,18 @@ repositories {
1617

1718
dependencies {
1819
implementation "org.komamitsu:spring-data-sqlite:${springDataSqliteVersion}"
19-
implementation platform('org.springframework.boot:spring-boot-dependencies:3.3.5')
20+
if (springBootVersion == '3') {
21+
implementation platform('org.springframework.boot:spring-boot-dependencies:3.3.5')
22+
implementation 'org.springframework.boot:spring-boot-starter-aop'
23+
implementation 'org.springframework.retry:spring-retry:1.3.4'
24+
} else {
25+
implementation platform('org.springframework.boot:spring-boot-dependencies:4.0.1')
26+
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
27+
implementation 'org.springframework:spring-aop'
28+
implementation 'org.aspectj:aspectjweaver'
29+
implementation 'org.springframework.retry:spring-retry:2.0.11'
30+
}
2031
implementation 'org.springframework.boot:spring-boot-starter'
21-
implementation 'org.springframework.boot:spring-boot-starter-aop'
22-
implementation 'org.springframework.retry:spring-retry:1.3.4'
2332
implementation 'com.zaxxer:HikariCP:4.0.3'
2433
implementation 'org.slf4j:slf4j-api'
2534
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'

src/main/java/org/komamitsu/spring/data/sqlite/EnableSqliteRepositories.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,17 +115,29 @@
115115
* namedParameterJdbcTemplate}.
116116
*
117117
* @return jdbc operations ref
118+
* @deprecated since 4.0, use {@link #jdbcAggregateOperationsRef()} instead.
118119
*/
120+
@Deprecated
119121
String jdbcOperationsRef() default "";
120122

123+
/**
124+
* Configures the name of the {@link org.springframework.data.jdbc.core.JdbcAggregateOperations}
125+
* bean definition to be used to create repositories discovered through this annotation.
126+
*
127+
* @return jdbc aggregate operations ref
128+
*/
129+
String jdbcAggregateOperationsRef() default "";
130+
121131
/**
122132
* Configures the name of the {@link
123133
* org.springframework.data.jdbc.core.convert.DataAccessStrategy} bean definition to be used to
124134
* create repositories discovered through this annotation. Defaults to {@code
125135
* defaultDataAccessStrategy}.
126136
*
127137
* @return data access strategy ref
138+
* @deprecated since 4.0, use {@link #jdbcAggregateOperationsRef()} instead.
128139
*/
140+
@Deprecated
129141
String dataAccessStrategyRef() default "";
130142

131143
/**
@@ -143,4 +155,14 @@
143155
* @return query lookup strategy
144156
*/
145157
QueryLookupStrategy.Key queryLookupStrategy() default QueryLookupStrategy.Key.CREATE_IF_NOT_FOUND;
158+
159+
/**
160+
* Configures whether to enable default transactions for Spring Data JDBC repositories. If
161+
* disabled, repositories must be used behind a facade that's configuring transactions (e.g. using
162+
* Spring's annotation driven transaction facilities) or repository methods have to be used to
163+
* demarcate transactions.
164+
*
165+
* @return whether to enable default transactions
166+
*/
167+
boolean enableDefaultTransactions() default true;
146168
}

src/main/java/org/komamitsu/spring/data/sqlite/SqliteDialect.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
import org.springframework.data.relational.core.dialect.LimitClause;
55
import org.springframework.data.relational.core.dialect.LockClause;
66
import org.springframework.data.relational.core.sql.IdentifierProcessing;
7-
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
8-
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
97
import org.springframework.data.relational.core.sql.LockOptions;
108

119
/**
@@ -63,8 +61,25 @@ public LockClause lock() {
6361
return LOCK_CLAUSE;
6462
}
6563

64+
// Custom implementation to avoid binary incompatibility between Spring Data 3.x and 4.x.
65+
// The return type of IdentifierProcessing.create() changed from DefaultIdentifierProcessing to
66+
// IdentifierProcessing, which causes NoSuchMethodError when compiled against one version and
67+
// run against the other.
68+
private static final IdentifierProcessing IDENTIFIER_PROCESSING =
69+
new IdentifierProcessing() {
70+
@Override
71+
public String quote(String identifier) {
72+
return "\"" + identifier + "\"";
73+
}
74+
75+
@Override
76+
public String standardizeLetterCase(String identifier) {
77+
return identifier.toLowerCase();
78+
}
79+
};
80+
6681
@Override
6782
public IdentifierProcessing getIdentifierProcessing() {
68-
return IdentifierProcessing.create(Quoting.ANSI, LetterCasing.LOWER_CASE);
83+
return IDENTIFIER_PROCESSING;
6984
}
7085
}

0 commit comments

Comments
 (0)