Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ name: Java CI

on:
push:
branches-ignore:
- 'compatibility-check-spring6'
pull_request:

jobs:
Expand All @@ -28,7 +26,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
java: [11, 17, 18, 19-ea]
java: [17, 18, 19-ea]
distribution: ['zulu']
fail-fast: false
max-parallel: 5
Expand All @@ -42,4 +40,4 @@ jobs:
java-version: ${{ matrix.java }}
distribution: ${{ matrix.distribution }}
- name: Test with Maven
run: ./mvnw test -B -D"license.skip=true"
run: ./mvnw test -B -D"license.skip=true" -D"enforcer.skip=true"
57 changes: 0 additions & 57 deletions .github/workflows/compatibility-check-spring6.yaml

This file was deleted.

8 changes: 3 additions & 5 deletions .github/workflows/coveralls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ name: Coveralls

on:
push:
branches-ignore:
- 'compatibility-check-spring6'
pull_request:

jobs:
Expand All @@ -31,16 +29,16 @@ jobs:
- name: Set up JDK
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: zulu
- name: Report Coverage to Coveralls for Pull Requests
if: github.event_name == 'pull_request'
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
- name: Report Coverage to Coveralls for General Push
if: github.event_name == 'push'
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github
run: ./mvnw test jacoco:report coveralls:report -q -Dlicense.skip=true -Denforcer.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/sonar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ name: SonarCloud
on:
push:
branches:
- master
- 3.x

jobs:
build:
Expand All @@ -36,7 +36,7 @@ jobs:
java-version: 17
distribution: zulu
- name: Analyze with SonarCloud
run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true
run: ./mvnw verify jacoco:report sonar:sonar -B -Dsonar.projectKey=mybatis_spring -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=$SONAR_TOKEN -Dlicense.skip=true -Denforcer.skip=true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/sonatype.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ name: Sonatype
on:
push:
branches:
- master
- 3.x

jobs:
build:
Expand All @@ -33,7 +33,7 @@ jobs:
java-version: 17
distribution: zulu
- name: Deploy to Sonatype
run: ./mvnw deploy -DskipTests -B --settings ./.mvn/settings.xml -Dlicense.skip=true
run: ./mvnw deploy -DskipTests -Denforcer.skip=true -B --settings ./.mvn/settings.xml -Dlicense.skip=true
env:
CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
47 changes: 0 additions & 47 deletions .github/workflows/support.yaml

This file was deleted.

43 changes: 39 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,13 @@
<osgi.dynamicImport>*</osgi.dynamicImport>

<mybatis.version>3.5.10</mybatis.version>
<spring.version>5.3.22</spring.version>
<spring-batch.version>4.3.6</spring-batch.version>
<spring.version>6.0.0-SNAPSHOT</spring.version>
<spring-batch.version>5.0.0-SNAPSHOT</spring-batch.version>
<module.name>org.mybatis.spring</module.name>

<junit.version>5.9.0</junit.version>
<project.build.outputTimestamp>1645112687</project.build.outputTimestamp>

</properties>

<dependencies>
Expand Down Expand Up @@ -295,13 +296,13 @@
<dependency>
<groupId>jakarta.transaction</groupId>
<artifactId>jakarta.transaction-api</artifactId>
<version>1.3.3</version>
<version>2.0.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>jakarta.servlet</groupId>
<artifactId>jakarta.servlet-api</artifactId>
<version>4.0.4</version>
<version>6.0.0</version>
<scope>test</scope>
</dependency>

Expand Down Expand Up @@ -371,6 +372,40 @@
<name>Sonatype OSS Snapshots Repository</name>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>spring-snapshot</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</repository>
<repository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>spring-snapshot</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<releases>
<enabled>false</enabled>
</releases>
</pluginRepository>
<pluginRepository>
<id>spring-milestone</id>
<name>Spring Milestone</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.mybatis.logging.Logger;
import org.mybatis.logging.LoggerFactory;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.batch.item.Chunk;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.core.convert.converter.Converter;
Expand Down Expand Up @@ -136,7 +137,7 @@ public void afterPropertiesSet() {
* {@inheritDoc}
*/
@Override
public void write(final List<? extends T> items) {
public void write(final Chunk<? extends T> items) {

if (!items.isEmpty()) {
LOGGER.debug(() -> "Executing batch with " + items.size() + " items.");
Expand All @@ -158,8 +159,8 @@ public void write(final List<? extends T> items) {
for (int i = 0; i < updateCounts.length; i++) {
int value = updateCounts[i];
if (value == 0) {
throw new EmptyResultDataAccessException(
"Item " + i + " of " + updateCounts.length + " did not update any rows: [" + items.get(i) + "]", 1);
throw new EmptyResultDataAccessException("Item " + i + " of " + updateCounts.length
+ " did not update any rows: [" + items.getItems().get(i) + "]", 1);
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/test/java/org/mybatis/spring/MyBatisSpringTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.fail;

import com.mockrunner.mock.ejb.MockUserTransaction;
import com.mockrunner.mock.jdbc.MockConnection;
import com.mockrunner.mock.jdbc.MockDataSource;
import com.mockrunner.mock.jdbc.MockPreparedStatement;
Expand All @@ -32,12 +31,15 @@
import org.apache.ibatis.transaction.managed.ManagedTransactionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import org.springframework.dao.DataAccessException;
import org.springframework.dao.TransientDataAccessResourceException;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.jta.JtaTransactionManager;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import jakarta.transaction.UserTransaction;

class MyBatisSpringTest extends AbstractMyBatisSpringTest {

private SqlSession session;
Expand Down Expand Up @@ -275,7 +277,7 @@ void testChangeExecutorTypeInTxRequiresNew() throws Exception {

@Test
void testWithJtaTxManager() {
JtaTransactionManager jtaManager = new JtaTransactionManager(new MockUserTransaction());
JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class));

DefaultTransactionDefinition txDef = new DefaultTransactionDefinition();
txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED");
Expand Down Expand Up @@ -304,7 +306,7 @@ void testWithJtaTxManagerAndNonSpringTxManager() throws java.sql.SQLException {
Environment nonSpring = new Environment("non-spring", new ManagedTransactionFactory(), mockDataSource);
sqlSessionFactory.getConfiguration().setEnvironment(nonSpring);

JtaTransactionManager jtaManager = new JtaTransactionManager(new MockUserTransaction());
JtaTransactionManager jtaManager = new JtaTransactionManager(Mockito.mock(UserTransaction.class));

DefaultTransactionDefinition txDef = new DefaultTransactionDefinition();
txDef.setPropagationBehaviorName("PROPAGATION_REQUIRED");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,13 @@
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.executor.BatchResult;
import org.apache.ibatis.session.ExecutorType;
import org.assertj.core.util.Lists;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
Expand All @@ -39,6 +37,7 @@
import org.mockito.MockitoAnnotations;
import org.mybatis.spring.SqlSessionTemplate;
import org.mybatis.spring.batch.domain.Employee;
import org.springframework.batch.item.Chunk;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.dao.InvalidDataAccessResourceUsageException;

Expand All @@ -60,8 +59,8 @@ void setUp() {

@Test
void testZeroBatchResultShouldThrowException() {
List<Employee> employees = Arrays.asList(new Employee(), new Employee());
List<BatchResult> batchResults = Lists.emptyList();
Chunk<Employee> employees = Chunk.of(new Employee(), new Employee());
List<BatchResult> batchResults = Collections.emptyList();

given(mockSqlSessionTemplate.flushStatements()).willReturn(batchResults);

Expand All @@ -70,7 +69,7 @@ void testZeroBatchResultShouldThrowException() {

@Test
void testZeroUpdateCountShouldThrowException() {
List<Employee> employees = Arrays.asList(new Employee(), new Employee());
Chunk<Employee> employees = Chunk.of(new Employee(), new Employee());

BatchResult batchResult = new BatchResult(null, null);
batchResult.setUpdateCounts(new int[] { 1, 0 });
Expand All @@ -87,7 +86,7 @@ void testItemToParameterConverterIsDefault() {
this.writer.setStatementId("updateEmployee");

Employee employee = new Employee();
List<Employee> employees = Collections.singletonList(employee);
Chunk<Employee> employees = Chunk.of(employee);
writer.write(employees);

Mockito.verify(this.mockSqlSessionTemplate).update("updateEmployee", employee);
Expand All @@ -105,7 +104,7 @@ void testSetItemToParameterConverter() {
});

Employee employee = new Employee();
List<Employee> employees = Collections.singletonList(employee);
Chunk<Employee> employees = Chunk.of(employee);
writer.write(employees);

Map<String, Object> parameter = new HashMap<>();
Expand Down
Loading