diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java index b20a55a7a9..c32394f140 100644 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -20,12 +20,12 @@ public class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "0.5.3"; + private static final String WRAPPER_VERSION = "0.5.5"; /** * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. */ private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" - + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + " .jar"; + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; /** * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties index 33ccdc4c9a..fa87ad7ddf 100644 --- a/.mvn/wrapper/maven-wrapper.properties +++ b/.mvn/wrapper/maven-wrapper.properties @@ -1,3 +1,2 @@ distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.1/apache-maven-3.6.1-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar - +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar diff --git a/.travis.yml b/.travis.yml index a427b76232..982f8be0ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,11 @@ language: java jdk: - openjdk12 - openjdk11 - - oraclejdk8 + - openjdk8 + +script: + - ./mvnw clean verify + - ./mvnw clean verify -Dspring.version=5.2.0.RELEASE -Dspring-batch.version=4.2.0.RELEASE -Denforcer.fail=false after_success: - chmod -R 777 ./travis/after_success.sh diff --git a/README.md b/README.md index 95f4235b90..c9998ae095 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ MyBatis Spring Adapter [![Build Status](https://travis-ci.org/mybatis/spring.svg?branch=master)](https://travis-ci.org/mybatis/spring) [![Coverage Status](https://coveralls.io/repos/mybatis/spring/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/spring?branch=master) [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis/mybatis-spring) -[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring) +[![Sonatype Nexus (Snapshots)](https://img.shields.io/nexus/s/https/oss.sonatype.org/org.mybatis/mybatis-spring.svg)](https://oss.sonatype.org/content/repositories/snapshots/org/mybatis/mybatis-spring/) [![License](http://img.shields.io/:license-apache-brightgreen.svg)](http://www.apache.org/licenses/LICENSE-2.0.html) ![mybatis-spring](http://mybatis.github.io/images/mybatis-logo.png) diff --git a/mvnw b/mvnw index 34d9dae8d0..d2f0ea3808 100755 --- a/mvnw +++ b/mvnw @@ -212,9 +212,9 @@ else echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." fi if [ -n "$MVNW_REPOURL" ]; then - jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" else - jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" fi while IFS="=" read key value; do case "$key" in (wrapperUrl) jarUrl="$value"; break ;; @@ -296,6 +296,11 @@ if $cygwin; then MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` fi +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain exec "$JAVACMD" \ diff --git a/mvnw.cmd b/mvnw.cmd index 77b451d837..b26ab24f03 100644 --- a/mvnw.cmd +++ b/mvnw.cmd @@ -37,7 +37,7 @@ @echo off @REM set title of command window title %0 -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% @REM set %HOME% to equivalent of $HOME @@ -120,7 +120,7 @@ SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain -set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B @@ -129,14 +129,18 @@ FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven- @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central @REM This allows using the maven wrapper in projects that prohibit checking in binary data. if exist %WRAPPER_JAR% ( - echo Found %WRAPPER_JAR% + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) ) else ( - if not "%MVNW_REPOURL%" == "" ( - SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.3/maven-wrapper-0.5.3.jar" - ) - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %DOWNLOAD_URL% - + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.5/maven-wrapper-0.5.5.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + powershell -Command "&{"^ "$webclient = new-object System.Net.WebClient;"^ "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ @@ -144,10 +148,16 @@ if exist %WRAPPER_JAR% ( "}"^ "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ "}" - echo Finished downloading %WRAPPER_JAR% + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) ) @REM End of extension +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* if ERRORLEVEL 1 goto error goto end diff --git a/pom.xml b/pom.xml index c816a08c8d..63ac682afd 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ mybatis-spring - 2.0.2 + 2.0.3 jar mybatis-spring @@ -80,7 +80,7 @@ http://github.com/mybatis/spring scm:git:ssh://github.com/mybatis/spring.git scm:git:ssh://git@github.com/mybatis/spring.git - mybatis-spring-2.0.2 + mybatis-spring-2.0.3 GitHub Issue Management @@ -105,8 +105,8 @@ org.springframework.batch.*;resolution:=optional,* * - 3.5.2 - 5.1.8.RELEASE + 3.5.3 + 5.1.10.RELEASE 4.1.2.RELEASE org.mybatis.spring diff --git a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java index f98cf6b126..1f917ff535 100644 --- a/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java +++ b/src/main/java/org/mybatis/spring/MyBatisExceptionTranslator.java @@ -16,6 +16,7 @@ package org.mybatis.spring; import java.sql.SQLException; +import java.util.function.Supplier; import javax.sql.DataSource; @@ -37,12 +38,11 @@ */ public class MyBatisExceptionTranslator implements PersistenceExceptionTranslator { - private final DataSource dataSource; - + private final Supplier exceptionTranslatorSupplier; private SQLExceptionTranslator exceptionTranslator; /** - * Creates a new {@code DataAccessExceptionTranslator} instance. + * Creates a new {@code PersistenceExceptionTranslator} instance with {@code SQLErrorCodeSQLExceptionTranslator}. * * @param dataSource * DataSource to use to find metadata and establish which error codes are usable. @@ -51,8 +51,22 @@ public class MyBatisExceptionTranslator implements PersistenceExceptionTranslato * exceptions. */ public MyBatisExceptionTranslator(DataSource dataSource, boolean exceptionTranslatorLazyInit) { - this.dataSource = dataSource; + this(() -> new SQLErrorCodeSQLExceptionTranslator(dataSource), exceptionTranslatorLazyInit); + } + /** + * Creates a new {@code PersistenceExceptionTranslator} instance with specified {@code SQLExceptionTranslator}. + * + * @param exceptionTranslatorSupplier + * Supplier for creating a {@code SQLExceptionTranslator} instance + * @param exceptionTranslatorLazyInit + * if true, the translator instantiates internal stuff only the first time will have the need to translate + * exceptions. + * @since 2.0.3 + */ + public MyBatisExceptionTranslator(Supplier exceptionTranslatorSupplier, + boolean exceptionTranslatorLazyInit) { + this.exceptionTranslatorSupplier = exceptionTranslatorSupplier; if (!exceptionTranslatorLazyInit) { this.initExceptionTranslator(); } @@ -85,7 +99,7 @@ public DataAccessException translateExceptionIfPossible(RuntimeException e) { */ private synchronized void initExceptionTranslator() { if (this.exceptionTranslator == null) { - this.exceptionTranslator = new SQLErrorCodeSQLExceptionTranslator(this.dataSource); + this.exceptionTranslator = exceptionTranslatorSupplier.get(); } } diff --git a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java index 3db0b2ce56..fb7463e168 100644 --- a/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java +++ b/src/main/java/org/mybatis/spring/SqlSessionFactoryBean.java @@ -186,7 +186,7 @@ public void setDatabaseIdProvider(DatabaseIdProvider databaseIdProvider) { /** * Gets the VFS. - * + * * @return a specified VFS */ public Class getVfs() { @@ -195,7 +195,7 @@ public Class getVfs() { /** * Sets the VFS. - * + * * @param vfs * a VFS */ @@ -205,7 +205,7 @@ public void setVfs(Class vfs) { /** * Gets the Cache. - * + * * @return a specified Cache */ public Cache getCache() { @@ -214,7 +214,7 @@ public Cache getCache() { /** * Sets the Cache. - * + * * @param cache * a Cache */ @@ -270,7 +270,7 @@ public void setTypeAliasesSuperType(Class typeAliasesSuperType) { * *

* Since 2.0.1, allow to specify a wildcard such as {@code com.example.*.typehandler}. - * + * * @since 1.0.1 * * @param typeHandlersPackage @@ -331,7 +331,7 @@ public void setConfigLocation(Resource configLocation) { /** * Set a customized MyBatis configuration. - * + * * @param configuration * MyBatis configuration * @since 1.3.0 @@ -535,7 +535,6 @@ protected SqlSessionFactory buildSqlSessionFactory() throws Exception { if (hasLength(this.typeHandlersPackage)) { scanClasses(this.typeHandlersPackage, TypeHandler.class).stream().filter(clazz -> !clazz.isAnonymousClass()) .filter(clazz -> !clazz.isInterface()).filter(clazz -> !Modifier.isAbstract(clazz.getModifiers())) - .filter(clazz -> ClassUtils.getConstructorIfAvailable(clazz) != null) .forEach(targetConfiguration.getTypeHandlerRegistry()::register); } diff --git a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java index f51f898522..19e16fe7e8 100644 --- a/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java +++ b/src/main/java/org/mybatis/spring/batch/MyBatisBatchItemWriter.java @@ -64,8 +64,8 @@ public class MyBatisBatchItemWriter implements ItemWriter, InitializingBea private Converter itemToParameterConverter = new PassThroughConverter<>(); /** - * Public setter for the flag that determines whether an assertion is made that all items cause at least one row to be - * updated. + * Public setter for the flag that determines whether an assertion is made that number of BatchResult objects returned + * is one and all items cause at least one row to be updated. * * @param assertUpdates * the flag to set. Defaults to true; diff --git a/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java b/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java new file mode 100644 index 0000000000..b1935e3c01 --- /dev/null +++ b/src/test/java/org/mybatis/core/jdk/type/AtomicNumberTypeHandler.java @@ -0,0 +1,54 @@ +/** + * Copyright 2010-2019 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.mybatis.core.jdk.type; + +import java.sql.CallableStatement; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; + +import org.apache.ibatis.type.JdbcType; +import org.apache.ibatis.type.MappedTypes; +import org.apache.ibatis.type.TypeHandler; + +@MappedTypes({ AtomicInteger.class, AtomicLong.class }) +public class AtomicNumberTypeHandler implements TypeHandler { + + public AtomicNumberTypeHandler(Class type) { + } + + @Override + public void setParameter(PreparedStatement ps, int i, Number parameter, JdbcType jdbcType) throws SQLException { + } + + @Override + public Number getResult(ResultSet rs, String columnName) throws SQLException { + return null; + } + + @Override + public Number getResult(CallableStatement cs, int columnIndex) throws SQLException { + return null; + } + + @Override + public Number getResult(ResultSet rs, int columnIndex) throws SQLException { + return null; + } + +} diff --git a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java index 396c8011d1..d373ff51db 100644 --- a/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java +++ b/src/test/java/org/mybatis/spring/SqlSessionFactoryBeanTest.java @@ -22,6 +22,8 @@ import java.math.BigInteger; import java.util.Properties; import java.util.UUID; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicLong; import org.apache.ibatis.cache.impl.PerpetualCache; import org.apache.ibatis.io.JBoss6VFS; @@ -43,6 +45,7 @@ import org.apache.ibatis.type.TypeHandler; import org.apache.ibatis.type.TypeHandlerRegistry; import org.junit.jupiter.api.Test; +import org.mybatis.core.jdk.type.AtomicNumberTypeHandler; import org.mybatis.spring.transaction.SpringManagedTransactionFactory; import org.mybatis.spring.type.DummyTypeAlias; import org.mybatis.spring.type.DummyTypeHandler; @@ -400,12 +403,14 @@ void testSearchATypeAliasPackageWithSamePackage() throws Exception { @Test void testSearchATypeHandlerPackage() throws Exception { setupFactoryBean(); - factoryBean.setTypeHandlersPackage("org.**.type"); + factoryBean.setTypeHandlersPackage("org.mybatis.**.type"); TypeHandlerRegistry typeHandlerRegistry = factoryBean.getObject().getConfiguration().getTypeHandlerRegistry(); assertThat(typeHandlerRegistry.hasTypeHandler(BigInteger.class)).isTrue(); assertThat(typeHandlerRegistry.hasTypeHandler(BigDecimal.class)).isTrue(); assertThat(typeHandlerRegistry.getTypeHandler(UUID.class)).isInstanceOf(TypeHandlerFactory.InnerTypeHandler.class); + assertThat(typeHandlerRegistry.getTypeHandler(AtomicInteger.class)).isInstanceOf(AtomicNumberTypeHandler.class); + assertThat(typeHandlerRegistry.getTypeHandler(AtomicLong.class)).isInstanceOf(AtomicNumberTypeHandler.class); } @Test diff --git a/travis/after_success.sh b/travis/after_success.sh index ee45ba6b5b..d8e4c7bb89 100644 --- a/travis/after_success.sh +++ b/travis/after_success.sh @@ -34,7 +34,7 @@ echo "Current commit detected: ${commit_message}" if [ $TRAVIS_REPO_SLUG == "mybatis/spring" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ] && [ "$TRAVIS_BRANCH" == "master" ] && [[ "$commit_message" != *"[maven-release-plugin]"* ]]; then - if [ $TRAVIS_JDK_VERSION == "oraclejdk8" ]; then + if [ $TRAVIS_JDK_VERSION == "openjdk8" ]; then # Deploy to sonatype ./mvnw clean deploy -q --settings ./travis/settings.xml @@ -50,7 +50,7 @@ if [ $TRAVIS_REPO_SLUG == "mybatis/spring" ] && [ "$TRAVIS_PULL_REQUEST" == "fal # echo -e "Successfully deploy site under Travis job ${TRAVIS_JOB_NUMBER}" # Notify Sonar - ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=ccf0be39fd0ca5ea5aa712247c79da7233cd3caa + ./mvnw clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=ccf0be39fd0ca5ea5aa712247c79da7233cd3caa echo -e "Successfully ran Sonar integration under Travis job ${TRAVIS_JOB_NUMBER}" else echo "Java Version does not support additonal activity for travis CI" pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy