diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index ceae4deb..00000000 --- a/.gitattributes +++ /dev/null @@ -1,2 +0,0 @@ -# Set default behaviour, in case users don't have core.autocrlf set. -* text=auto diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml deleted file mode 100644 index 6df21c05..00000000 --- a/.github/workflows/ci.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Java CI - -on: [workflow_dispatch, push, pull_request] - -permissions: read-all - -jobs: - test: - runs-on: ${{ matrix.os }} - strategy: - matrix: - cache: [maven] - distribution: [temurin] - java: [17, 21, 24, 25-ea] - os: [ubuntu-latest, macos-latest, windows-latest] - fail-fast: false - max-parallel: 4 - name: Test JDK ${{ matrix.java }}, ${{ matrix.os }} - - steps: - - uses: actions/checkout@v4 - - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }} - uses: actions/setup-java@v4 - with: - java-version: ${{ matrix.java }} - distribution: ${{ matrix.distribution }} - cache: ${{ matrix.cache }} - - name: Test with Maven - run: ./mvnw test -B -V --no-transfer-progress -D"license.skip=true" diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml deleted file mode 100644 index 67b0e362..00000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,49 +0,0 @@ -name: "CodeQL" - -on: - push: - branches: [ master ] - pull_request: - branches: [ master ] - schedule: - - cron: '26 6 * * 6' - -jobs: - analyze: - name: Analyze - runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }} - timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }} - permissions: - actions: read - contents: read - security-events: write - - strategy: - fail-fast: false - matrix: - language: [ 'java-kotlin' ] - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Setup Java - uses: actions/setup-java@v4 - with: - cache: maven - distribution: 'temurin' - java-version: 21 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v3 - with: - languages: ${{ matrix.language }} - queries: +security-and-quality - - - name: Autobuild - uses: github/codeql-action/autobuild@v3 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v3 - with: - category: "/language:${{ matrix.language }}" diff --git a/.github/workflows/coveralls.yaml b/.github/workflows/coveralls.yaml deleted file mode 100644 index b4aaaa99..00000000 --- a/.github/workflows/coveralls.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: Coveralls - -on: [push, pull_request] - -permissions: read-all - -jobs: - build: - if: github.repository_owner == 'mybatis' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - cache: maven - distribution: temurin - java-version: 21 - - name: Report Coverage to Coveralls for Pull Requests - if: github.event_name == 'pull_request' - run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress - 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 -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/site.yaml b/.github/workflows/site.yaml deleted file mode 100644 index de1babe4..00000000 --- a/.github/workflows/site.yaml +++ /dev/null @@ -1,32 +0,0 @@ -name: Site - -on: - push: - branches: - - site - -permissions: - contents: write - -jobs: - build: - if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - cache: maven - distribution: temurin - java-version: 21 - - name: Build site - run: ./mvnw site site:stage -DskipTests -Dlicense.skip=true -B -V --no-transfer-progress --settings ./.mvn/settings.xml - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NVD_API_KEY: ${{ secrets.NVD_API_KEY }} - - name: Deploy Site to gh-pages - uses: JamesIves/github-pages-deploy-action@v4 - with: - branch: gh-pages - folder: target/staging diff --git a/.github/workflows/sonar.yaml b/.github/workflows/sonar.yaml deleted file mode 100644 index aa160116..00000000 --- a/.github/workflows/sonar.yaml +++ /dev/null @@ -1,29 +0,0 @@ -name: SonarCloud - -on: - push: - branches: - - master - -permissions: read-all - -jobs: - build: - if: github.repository_owner == 'mybatis' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - # Disabling shallow clone is recommended for improving relevancy of reporting - fetch-depth: 0 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - cache: maven - distribution: temurin - java-version: 21 - - name: Analyze with SonarCloud - run: ./mvnw verify jacoco:report sonar:sonar -B -V -Dsonar.projectKey=mybatis_scala -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/sonatype.yaml b/.github/workflows/sonatype.yaml deleted file mode 100644 index c922f382..00000000 --- a/.github/workflows/sonatype.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Sonatype - -on: - push: - branches: - - master - -permissions: read-all - -jobs: - build: - if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]') - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - cache: maven - distribution: temurin - java-version: 21 - - name: Deploy to Sonatype - run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true - env: - CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }} - CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }} diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 08f3c54d..00000000 --- a/.gitignore +++ /dev/null @@ -1,224 +0,0 @@ -# / -/target -/nbproject -/catalog.xml -/.build.sbt.swp -/.ensime_port -/.ensime - -# /mybatis-scala-core/ -/mybatis-scala-core/target -/mybatis-scala-core/nbproject -/mybatis-scala-core/catalog.xml -/mybatis-scala-core/.build.sbt.swp -/mybatis-scala-core/.cache -/mybatis-scala-core/.classpath -/mybatis-scala-core/.project - -# /mybatis-scala-core/src/ -/mybatis-scala-core/src/target -/mybatis-scala-core/src/nbproject -/mybatis-scala-core/src/catalog.xml - -# /mybatis-scala-core/src/main/ -/mybatis-scala-core/src/main/target -/mybatis-scala-core/src/main/nbproject -/mybatis-scala-core/src/main/catalog.xml - -# /mybatis-scala-core/src/main/scala/ -/mybatis-scala-core/src/main/scala/target -/mybatis-scala-core/src/main/scala/nbproject -/mybatis-scala-core/src/main/scala/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/ -/mybatis-scala-core/src/main/scala/org/target -/mybatis-scala-core/src/main/scala/org/nbproject -/mybatis-scala-core/src/main/scala/org/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/ -/mybatis-scala-core/src/main/scala/org/mybatis/target -/mybatis-scala-core/src/main/scala/org/mybatis/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/scala/ -/mybatis-scala-core/src/main/scala/org/mybatis/scala/target -/mybatis-scala-core/src/main/scala/org/mybatis/scala/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/scala/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/ -/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/target -/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ -/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/target -/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ -/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/target -/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/catalog.xml - -# /mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ -/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/target -/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/nbproject -/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/catalog.xml - -# /mybatis-scala-core/src/site/ -/mybatis-scala-core/src/site/target -/mybatis-scala-core/src/site/nbproject -/mybatis-scala-core/src/site/catalog.xml - -# /mybatis-scala-core/src/site/xdoc/ -/mybatis-scala-core/src/site/xdoc/target -/mybatis-scala-core/src/site/xdoc/nbproject -/mybatis-scala-core/src/site/xdoc/catalog.xml - -# /mybatis-scala-core/src/test/ -/mybatis-scala-core/src/test/target -/mybatis-scala-core/src/test/nbproject -/mybatis-scala-core/src/test/catalog.xml - -# /mybatis-scala-core/src/test/scala/ -/mybatis-scala-core/src/test/scala/target -/mybatis-scala-core/src/test/scala/nbproject -/mybatis-scala-core/src/test/scala/catalog.xml - -# /mybatis-scala-samples/ -/mybatis-scala-samples/target -/mybatis-scala-samples/nbproject -/mybatis-scala-samples/catalog.xml -/mybatis-scala-samples/.build.sbt.swp -/mybatis-scala-samples/project/target -/mybatis-scala-samples/.cache -/mybatis-scala-samples/.classpath -/mybatis-scala-samples/.project - -# /mybatis-scala-samples/project/ -/mybatis-scala-samples/project/target -/mybatis-scala-samples/project/nbproject -/mybatis-scala-samples/project/catalog.xml -/mybatis-scala-samples/project/.build.sbt.swp -/mybatis-scala-samples/project/project/target - -# /mybatis-scala-samples/src/ -/mybatis-scala-samples/src/target -/mybatis-scala-samples/src/nbproject -/mybatis-scala-samples/src/catalog.xml -/mybatis-scala-samples/src/.build.sbt.swp -/mybatis-scala-samples/src/project/target - -# /mybatis-scala-samples/src/main/ -/mybatis-scala-samples/src/main/target -/mybatis-scala-samples/src/main/nbproject -/mybatis-scala-samples/src/main/catalog.xml -/mybatis-scala-samples/src/main/.build.sbt.swp -/mybatis-scala-samples/src/main/project/target - -# /mybatis-scala-samples/src/main/resources/ -/mybatis-scala-samples/src/main/resources/target -/mybatis-scala-samples/src/main/resources/nbproject -/mybatis-scala-samples/src/main/resources/catalog.xml -/mybatis-scala-samples/src/main/resources/.build.sbt.swp -/mybatis-scala-samples/src/main/resources/project/target - -# /mybatis-scala-samples/src/main/scala/ -/mybatis-scala-samples/src/main/scala/target -/mybatis-scala-samples/src/main/scala/nbproject -/mybatis-scala-samples/src/main/scala/catalog.xml -/mybatis-scala-samples/src/main/scala/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/project/target - -# /mybatis-scala-samples/src/main/scala/org/ -/mybatis-scala-samples/src/main/scala/org/target -/mybatis-scala-samples/src/main/scala/org/nbproject -/mybatis-scala-samples/src/main/scala/org/catalog.xml -/mybatis-scala-samples/src/main/scala/org/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/org/project/target - -# /mybatis-scala-samples/src/main/scala/org/mybatis/ -/mybatis-scala-samples/src/main/scala/org/mybatis/target -/mybatis-scala-samples/src/main/scala/org/mybatis/nbproject -/mybatis-scala-samples/src/main/scala/org/mybatis/catalog.xml -/mybatis-scala-samples/src/main/scala/org/mybatis/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/org/mybatis/project/target - -# /mybatis-scala-samples/src/main/scala/org/mybatis/scala/ -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/target -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/nbproject -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/catalog.xml -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/project/target - -# /mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/ -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/target -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/nbproject -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/catalog.xml -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/project/target - -# /mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/ -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/target -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/nbproject -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/catalog.xml -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/.build.sbt.swp -/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/project/target - -# /mybatis-scala-samples/src/site/ -/mybatis-scala-samples/src/site/target -/mybatis-scala-samples/src/site/nbproject -/mybatis-scala-samples/src/site/catalog.xml -/mybatis-scala-samples/src/site/.build.sbt.swp -/mybatis-scala-samples/src/site/project/target - -# /mybatis-scala-samples/src/site/resources/ -/mybatis-scala-samples/src/site/resources/target -/mybatis-scala-samples/src/site/resources/nbproject -/mybatis-scala-samples/src/site/resources/catalog.xml -/mybatis-scala-samples/src/site/resources/.build.sbt.swp -/mybatis-scala-samples/src/site/resources/project/target - -# /mybatis-scala-samples/src/site/resources/images/ -/mybatis-scala-samples/src/site/resources/images/target -/mybatis-scala-samples/src/site/resources/images/nbproject -/mybatis-scala-samples/src/site/resources/images/catalog.xml -/mybatis-scala-samples/src/site/resources/images/.build.sbt.swp -/mybatis-scala-samples/src/site/resources/images/project/target - -# /mybatis-scala-samples/src/site/xdoc/ -/mybatis-scala-samples/src/site/xdoc/target -/mybatis-scala-samples/src/site/xdoc/nbproject -/mybatis-scala-samples/src/site/xdoc/catalog.xml -/mybatis-scala-samples/src/site/xdoc/.build.sbt.swp -/mybatis-scala-samples/src/site/xdoc/project/target - -# /mybatis-scala-samples/src/test/ -/mybatis-scala-samples/src/test/target -/mybatis-scala-samples/src/test/nbproject -/mybatis-scala-samples/src/test/catalog.xml -/mybatis-scala-samples/src/test/.build.sbt.swp -/mybatis-scala-samples/src/test/project/target - -# /mybatis-scala-samples/src/test/scala/ -/mybatis-scala-samples/src/test/scala/target -/mybatis-scala-samples/src/test/scala/nbproject -/mybatis-scala-samples/src/test/scala/catalog.xml -/mybatis-scala-samples/src/test/scala/.build.sbt.swp -/mybatis-scala-samples/src/test/scala/project/target - -# /project/ -/project/ -/project/target -/project/nbproject -/project/catalog.xml -/project/.Build.scala.swp -.project -.settings -.idea -*.iml -project -.mvn/wrapper/maven-wrapper.jar -pom.xml.releaseBackup -release.properties -.github/keys/ diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml deleted file mode 100644 index e0e273d1..00000000 --- a/.mvn/extensions.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - fr.jcgay.maven - maven-profiler - 3.3 - - diff --git a/.mvn/maven.config b/.mvn/maven.config deleted file mode 100644 index afdcfab7..00000000 --- a/.mvn/maven.config +++ /dev/null @@ -1,2 +0,0 @@ --Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5 --Daether.connector.smartChecksums=false diff --git a/.mvn/settings.xml b/.mvn/settings.xml deleted file mode 100644 index b4f1e0d2..00000000 --- a/.mvn/settings.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - central - ${env.CI_DEPLOY_USERNAME} - ${env.CI_DEPLOY_PASSWORD} - - - - - gh-pages-scm - - branch - gh-pages - - - - - - github - ${env.GITHUB_TOKEN} - - - - - nvd - ${env.NVD_API_KEY} - - - - diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java deleted file mode 100644 index bdf0ddfa..00000000 --- a/.mvn/wrapper/MavenWrapperDownloader.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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 - * - * https://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. - */ - -import java.io.IOException; -import java.io.InputStream; -import java.net.Authenticator; -import java.net.PasswordAuthentication; -import java.net.URI; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.nio.file.StandardCopyOption; -import java.util.concurrent.ThreadLocalRandom; - -public final class MavenWrapperDownloader { - private static final String WRAPPER_VERSION = "3.3.2"; - - private static final boolean VERBOSE = Boolean.parseBoolean(System.getenv("MVNW_VERBOSE")); - - public static void main(String[] args) { - log("Apache Maven Wrapper Downloader " + WRAPPER_VERSION); - - if (args.length != 2) { - System.err.println(" - ERROR wrapperUrl or wrapperJarPath parameter missing"); - System.exit(1); - } - - try { - log(" - Downloader started"); - final URL wrapperUrl = URI.create(args[0]).toURL(); - final String jarPath = args[1].replace("..", ""); // Sanitize path - final Path wrapperJarPath = Paths.get(jarPath).toAbsolutePath().normalize(); - downloadFileFromURL(wrapperUrl, wrapperJarPath); - log("Done"); - } catch (IOException e) { - System.err.println("- Error downloading: " + e.getMessage()); - if (VERBOSE) { - e.printStackTrace(); - } - System.exit(1); - } - } - - private static void downloadFileFromURL(URL wrapperUrl, Path wrapperJarPath) - throws IOException { - log(" - Downloading to: " + wrapperJarPath); - if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { - final String username = System.getenv("MVNW_USERNAME"); - final char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); - Authenticator.setDefault(new Authenticator() { - @Override - protected PasswordAuthentication getPasswordAuthentication() { - return new PasswordAuthentication(username, password); - } - }); - } - Path temp = wrapperJarPath - .getParent() - .resolve(wrapperJarPath.getFileName() + "." - + Long.toUnsignedString(ThreadLocalRandom.current().nextLong()) + ".tmp"); - try (InputStream inStream = wrapperUrl.openStream()) { - Files.copy(inStream, temp, StandardCopyOption.REPLACE_EXISTING); - Files.move(temp, wrapperJarPath, StandardCopyOption.REPLACE_EXISTING); - } finally { - Files.deleteIfExists(temp); - } - log(" - Downloader complete"); - } - - private static void log(String msg) { - if (VERBOSE) { - System.out.println(msg); - } - } - -} diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties deleted file mode 100644 index 0d35f6db..00000000 --- a/.mvn/wrapper/maven-wrapper.properties +++ /dev/null @@ -1,20 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# https://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. -wrapperVersion=3.3.2 -distributionType=source -distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.10/apache-maven-3.9.10-bin.zip -wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 7e835b2f..00000000 --- a/LICENSE +++ /dev/null @@ -1,202 +0,0 @@ - Apache License - Version 2.0, January 2004 - https://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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 - - https://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. - diff --git a/LICENSE_HEADER b/LICENSE_HEADER deleted file mode 100644 index a81590a5..00000000 --- a/LICENSE_HEADER +++ /dev/null @@ -1,13 +0,0 @@ - Copyright ${license.git.copyrightYears} 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 - - https://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. diff --git a/NOTICE b/NOTICE deleted file mode 100644 index 2d53df79..00000000 --- a/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -MyBatis Scala -Copyright 2011-2023 - -This product includes software developed by -The MyBatis Team (http://www.mybatis.org/). diff --git a/README.md b/README.md deleted file mode 100644 index de264e27..00000000 --- a/README.md +++ /dev/null @@ -1,22 +0,0 @@ -MyBatis Scala Adapter -===================== - -[![Java CI](https://github.com/mybatis/scala/workflows/Java%20CI/badge.svg)](https://github.com/mybatis/scala/actions/workflows/ci.yaml) -[![Coverage Status](https://coveralls.io/repos/mybatis/scala/badge.svg?branch=master&service=github)](https://coveralls.io/github/mybatis/scala?branch=master) -[![License](https://img.shields.io/:license-apache-brightgreen.svg)](https://www.apache.org/licenses/LICENSE-2.0.html) - -Versions -* **Scala 2.9.2** [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.9.2/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.9.2) -* **Scala 2.10** [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.10/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.10) -* **Scala 2.11** [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.11/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.11) -* **Scala 2.12** [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.12/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.12) -* **Scala 2.13** [![Maven central](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.13/badge.svg)](https://maven-badges.herokuapp.com/maven-central/org.mybatis.scala/mybatis-scala-core_2.13) - -![mybatis-logo](https://mybatis.org/images/mybatis-logo.png) - -MyBatis-Scala adapter for Scala. - -Essentials ----------- - -* [See the docs](https://mybatis.org/scala/) diff --git a/format.xml b/format.xml deleted file mode 100644 index f7d2bf45..00000000 --- a/format.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/mvnw b/mvnw deleted file mode 100755 index 66838882..00000000 --- a/mvnw +++ /dev/null @@ -1,332 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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 -# -# https://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. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Apache Maven Wrapper startup batch script, version 3.3.2 -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# MAVEN_SKIP_RC - flag to disable loading of mavenrc files -# ---------------------------------------------------------------------------- - -if [ -z "$MAVEN_SKIP_RC" ]; then - - if [ -f /usr/local/etc/mavenrc ]; then - . /usr/local/etc/mavenrc - fi - - if [ -f /etc/mavenrc ]; then - . /etc/mavenrc - fi - - if [ -f "$HOME/.mavenrc" ]; then - . "$HOME/.mavenrc" - fi - -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false -darwin=false -mingw=false -case "$(uname)" in -CYGWIN*) cygwin=true ;; -MINGW*) mingw=true ;; -Darwin*) - darwin=true - # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home - # See https://developer.apple.com/library/mac/qa/qa1170/_index.html - if [ -z "$JAVA_HOME" ]; then - if [ -x "/usr/libexec/java_home" ]; then - JAVA_HOME="$(/usr/libexec/java_home)" - export JAVA_HOME - else - JAVA_HOME="/Library/Java/Home" - export JAVA_HOME - fi - fi - ;; -esac - -if [ -z "$JAVA_HOME" ]; then - if [ -r /etc/gentoo-release ]; then - JAVA_HOME=$(java-config --jre-home) - fi -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin; then - [ -n "$JAVA_HOME" ] \ - && JAVA_HOME=$(cygpath --unix "$JAVA_HOME") - [ -n "$CLASSPATH" ] \ - && CLASSPATH=$(cygpath --path --unix "$CLASSPATH") -fi - -# For Mingw, ensure paths are in UNIX format before anything is touched -if $mingw; then - [ -n "$JAVA_HOME" ] && [ -d "$JAVA_HOME" ] \ - && JAVA_HOME="$( - cd "$JAVA_HOME" || ( - echo "cannot cd into $JAVA_HOME." >&2 - exit 1 - ) - pwd - )" -fi - -if [ -z "$JAVA_HOME" ]; then - javaExecutable="$(which javac)" - if [ -n "$javaExecutable" ] && ! [ "$(expr "$javaExecutable" : '\([^ ]*\)')" = "no" ]; then - # readlink(1) is not available as standard on Solaris 10. - readLink=$(which readlink) - if [ ! "$(expr "$readLink" : '\([^ ]*\)')" = "no" ]; then - if $darwin; then - javaHome="$(dirname "$javaExecutable")" - javaExecutable="$(cd "$javaHome" && pwd -P)/javac" - else - javaExecutable="$(readlink -f "$javaExecutable")" - fi - javaHome="$(dirname "$javaExecutable")" - javaHome=$(expr "$javaHome" : '\(.*\)/bin') - JAVA_HOME="$javaHome" - export JAVA_HOME - fi - fi -fi - -if [ -z "$JAVACMD" ]; then - if [ -n "$JAVA_HOME" ]; then - if [ -x "$JAVA_HOME/jre/sh/java" ]; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="$( - \unset -f command 2>/dev/null - \command -v java - )" - fi -fi - -if [ ! -x "$JAVACMD" ]; then - echo "Error: JAVA_HOME is not defined correctly." >&2 - echo " We cannot execute $JAVACMD" >&2 - exit 1 -fi - -if [ -z "$JAVA_HOME" ]; then - echo "Warning: JAVA_HOME environment variable is not set." >&2 -fi - -# traverses directory structure from process work directory to filesystem root -# first directory with .mvn subdirectory is considered project base directory -find_maven_basedir() { - if [ -z "$1" ]; then - echo "Path not specified to find_maven_basedir" >&2 - return 1 - fi - - basedir="$1" - wdir="$1" - while [ "$wdir" != '/' ]; do - if [ -d "$wdir"/.mvn ]; then - basedir=$wdir - break - fi - # workaround for JBEAP-8937 (on Solaris 10/Sparc) - if [ -d "${wdir}" ]; then - wdir=$( - cd "$wdir/.." || exit 1 - pwd - ) - fi - # end of workaround - done - printf '%s' "$( - cd "$basedir" || exit 1 - pwd - )" -} - -# concatenates all lines of a file -concat_lines() { - if [ -f "$1" ]; then - # Remove \r in case we run on Windows within Git Bash - # and check out the repository with auto CRLF management - # enabled. Otherwise, we may read lines that are delimited with - # \r\n and produce $'-Xarg\r' rather than -Xarg due to word - # splitting rules. - tr -s '\r\n' ' ' <"$1" - fi -} - -log() { - if [ "$MVNW_VERBOSE" = true ]; then - printf '%s\n' "$1" - fi -} - -BASE_DIR=$(find_maven_basedir "$(dirname "$0")") -if [ -z "$BASE_DIR" ]; then - exit 1 -fi - -MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} -export MAVEN_PROJECTBASEDIR -log "$MAVEN_PROJECTBASEDIR" - -########################################################################################## -# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central -# This allows using the maven wrapper in projects that prohibit checking in binary data. -########################################################################################## -wrapperJarPath="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" -if [ -r "$wrapperJarPath" ]; then - log "Found $wrapperJarPath" -else - log "Couldn't find $wrapperJarPath, downloading it ..." - - if [ -n "$MVNW_REPOURL" ]; then - wrapperUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" - else - wrapperUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" - fi - while IFS="=" read -r key value; do - # Remove '\r' from value to allow usage on windows as IFS does not consider '\r' as a separator ( considers space, tab, new line ('\n'), and custom '=' ) - safeValue=$(echo "$value" | tr -d '\r') - case "$key" in wrapperUrl) - wrapperUrl="$safeValue" - break - ;; - esac - done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" - log "Downloading from: $wrapperUrl" - - if $cygwin; then - wrapperJarPath=$(cygpath --path --windows "$wrapperJarPath") - fi - - if command -v wget >/dev/null; then - log "Found wget ... using wget" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--quiet" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - wget $QUIET "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - else - wget $QUIET --http-user="$MVNW_USERNAME" --http-password="$MVNW_PASSWORD" "$wrapperUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath" - fi - elif command -v curl >/dev/null; then - log "Found curl ... using curl" - [ "$MVNW_VERBOSE" = true ] && QUIET="" || QUIET="--silent" - if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then - curl $QUIET -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - else - curl $QUIET --user "$MVNW_USERNAME:$MVNW_PASSWORD" -o "$wrapperJarPath" "$wrapperUrl" -f -L || rm -f "$wrapperJarPath" - fi - else - log "Falling back to using Java to download" - javaSource="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.java" - javaClass="$MAVEN_PROJECTBASEDIR/.mvn/wrapper/MavenWrapperDownloader.class" - # For Cygwin, switch paths to Windows format before running javac - if $cygwin; then - javaSource=$(cygpath --path --windows "$javaSource") - javaClass=$(cygpath --path --windows "$javaClass") - fi - if [ -e "$javaSource" ]; then - if [ ! -e "$javaClass" ]; then - log " - Compiling MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/javac" "$javaSource") - fi - if [ -e "$javaClass" ]; then - log " - Running MavenWrapperDownloader.java ..." - ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$wrapperUrl" "$wrapperJarPath") || rm -f "$wrapperJarPath" - fi - fi - fi -fi -########################################################################################## -# End of extension -########################################################################################## - -# If specified, validate the SHA-256 sum of the Maven wrapper jar file -wrapperSha256Sum="" -while IFS="=" read -r key value; do - case "$key" in wrapperSha256Sum) - wrapperSha256Sum=$value - break - ;; - esac -done <"$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.properties" -if [ -n "$wrapperSha256Sum" ]; then - wrapperSha256Result=false - if command -v sha256sum >/dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | sha256sum -c >/dev/null 2>&1; then - wrapperSha256Result=true - fi - elif command -v shasum >/dev/null; then - if echo "$wrapperSha256Sum $wrapperJarPath" | shasum -a 256 -c >/dev/null 2>&1; then - wrapperSha256Result=true - fi - else - echo "Checksum validation was requested but neither 'sha256sum' or 'shasum' are available." >&2 - echo "Please install either command, or disable validation by removing 'wrapperSha256Sum' from your maven-wrapper.properties." >&2 - exit 1 - fi - if [ $wrapperSha256Result = false ]; then - echo "Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised." >&2 - echo "Investigate or delete $wrapperJarPath to attempt a clean download." >&2 - echo "If you updated your Maven version, you need to update the specified wrapperSha256Sum property." >&2 - exit 1 - fi -fi - -MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$JAVA_HOME" ] \ - && JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") - [ -n "$CLASSPATH" ] \ - && CLASSPATH=$(cygpath --path --windows "$CLASSPATH") - [ -n "$MAVEN_PROJECTBASEDIR" ] \ - && 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 - -# shellcheck disable=SC2086 # safe args -exec "$JAVACMD" \ - $MAVEN_OPTS \ - $MAVEN_DEBUG_OPTS \ - -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ - "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ - ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd deleted file mode 100644 index da4fe4dd..00000000 --- a/mvnw.cmd +++ /dev/null @@ -1,206 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM https://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Apache Maven Wrapper startup batch script, version 3.3.2 -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM set title of command window -title %0 -@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 -if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") - -@REM Execute a user defined script before this one -if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre -@REM check for pre script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %* -if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %* -:skipRcPre - -@setlocal - -set ERROR_CODE=0 - -@REM To isolate internal variables from possible post scripts, we use another setlocal -@setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. >&2 -echo Error: JAVA_HOME not found in your environment. >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. >&2 -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto init - -echo. >&2 -echo Error: JAVA_HOME is set to an invalid directory. >&2 -echo JAVA_HOME = "%JAVA_HOME%" >&2 -echo Please set the JAVA_HOME variable in your environment to match the >&2 -echo location of your Java installation. >&2 -echo. >&2 -goto error - -@REM ==== END VALIDATION ==== - -:init - -@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". -@REM Fallback to current working directory if not found. - -set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% -IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir - -set EXEC_DIR=%CD% -set WDIR=%EXEC_DIR% -:findBaseDir -IF EXIST "%WDIR%"\.mvn goto baseDirFound -cd .. -IF "%WDIR%"=="%CD%" goto baseDirNotFound -set WDIR=%CD% -goto findBaseDir - -:baseDirFound -set MAVEN_PROJECTBASEDIR=%WDIR% -cd "%EXEC_DIR%" -goto endDetectBaseDir - -:baseDirNotFound -set MAVEN_PROJECTBASEDIR=%EXEC_DIR% -cd "%EXEC_DIR%" - -:endDetectBaseDir - -IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig - -@setlocal EnableExtensions EnableDelayedExpansion -for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a -@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% - -:endReadAdditionalConfig - -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 WRAPPER_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" - -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperUrl" SET WRAPPER_URL=%%B -) - -@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% ( - if "%MVNW_VERBOSE%" == "true" ( - echo Found %WRAPPER_JAR% - ) -) else ( - if not "%MVNW_REPOURL%" == "" ( - SET WRAPPER_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar" - ) - if "%MVNW_VERBOSE%" == "true" ( - echo Couldn't find %WRAPPER_JAR%, downloading it ... - echo Downloading from: %WRAPPER_URL% - ) - - powershell -Command "&{"^ - "$webclient = new-object System.Net.WebClient;"^ - "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ - "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ - "}"^ - "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%WRAPPER_URL%', '%WRAPPER_JAR%')"^ - "}" - if "%MVNW_VERBOSE%" == "true" ( - echo Finished downloading %WRAPPER_JAR% - ) -) -@REM End of extension - -@REM If specified, validate the SHA-256 sum of the Maven wrapper jar file -SET WRAPPER_SHA_256_SUM="" -FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( - IF "%%A"=="wrapperSha256Sum" SET WRAPPER_SHA_256_SUM=%%B -) -IF NOT %WRAPPER_SHA_256_SUM%=="" ( - powershell -Command "&{"^ - "Import-Module $PSHOME\Modules\Microsoft.PowerShell.Utility -Function Get-FileHash;"^ - "$hash = (Get-FileHash \"%WRAPPER_JAR%\" -Algorithm SHA256).Hash.ToLower();"^ - "If('%WRAPPER_SHA_256_SUM%' -ne $hash){"^ - " Write-Error 'Error: Failed to validate Maven wrapper SHA-256, your Maven wrapper might be compromised.';"^ - " Write-Error 'Investigate or delete %WRAPPER_JAR% to attempt a clean download.';"^ - " Write-Error 'If you updated your Maven version, you need to update the specified wrapperSha256Sum property.';"^ - " exit 1;"^ - "}"^ - "}" - if ERRORLEVEL 1 goto error -) - -@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 - -:error -set ERROR_CODE=1 - -:end -@endlocal & set ERROR_CODE=%ERROR_CODE% - -if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost -@REM check for post script, once with legacy .bat ending and once with .cmd ending -if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat" -if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd" -:skipRcPost - -@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%"=="on" pause - -if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE% - -cmd /C exit /B %ERROR_CODE% diff --git a/mybatis-scala-core/LICENSE_HEADER b/mybatis-scala-core/LICENSE_HEADER deleted file mode 100644 index add5c3d1..00000000 --- a/mybatis-scala-core/LICENSE_HEADER +++ /dev/null @@ -1,13 +0,0 @@ - Copyright 2011-2015 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 - - https://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. diff --git a/mybatis-scala-core/format.xml b/mybatis-scala-core/format.xml deleted file mode 100644 index b66080b5..00000000 --- a/mybatis-scala-core/format.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/mybatis-scala-core/pom.xml b/mybatis-scala-core/pom.xml deleted file mode 100644 index 70be4f39..00000000 --- a/mybatis-scala-core/pom.xml +++ /dev/null @@ -1,135 +0,0 @@ - - - - 4.0.0 - - - org.mybatis.scala - mybatis-scala-parent_2.13 - 1.3.2-SNAPSHOT - - - mybatis-scala-core_2.13 - 1.3.2-SNAPSHOT - jar - mybatis-scala-core - - - scm:git:ssh://github.com/mybatis/scala.git - scm:git:ssh://git@github.com/mybatis/scala.git - HEAD - http://github.com/mybatis/scala - - - - - org.mybatis - mybatis - 3.5.19 - - - org.scala-lang - scala-library - - - org.scala-lang.modules - scala-xml_${scala.binary} - - - org.scalatest - scalatest_${scala.binary} - 3.2.19 - test - - - org.hsqldb - hsqldb - 2.7.4 - test - - - - - - - - META-INF - ${project.basedir}/../ - - LICENSE - NOTICE - - - - - - net.alchim31.maven - scala-maven-plugin - - - attach-javadocs - - doc-jar - - - - - - org.apache.maven.plugins - maven-site-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - org.scalatest - scalatest-maven-plugin - 2.2.0 - - ${project.build.directory}/surefire-reports - . - WDF TestSuite.txt - - - - test - - test - - - - - - - - - - - net.alchim31.maven - scala-maven-plugin - 4.9.5 - - - - - diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/package.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/package.scala deleted file mode 100644 index 2ea376ff..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/cache/package.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.apache.ibatis.cache.{Cache => MBCache} -import org.apache.ibatis.cache.impl.PerpetualCache -import org.mybatis.scala.mapping.T -import org.apache.ibatis.cache.decorators._ - -/** Provides Cache supporting types and objects */ -package object cache { - - /** Alias of [[org.apache.ibatis.cache.Cache]] */ - type Cache = MBCache - - /** Default MyBatis cache implementation: PerpetualCache */ - val DefaultCache = T[PerpetualCache] - - /** Default eviction policies */ - object Eviction { - - /** Least Recently Used: Removes objects that haven’t been used for the longest period of time. */ - val LRU = T[LruCache] - - /** First In First Out: Removes objects in the order that they entered the cache. */ - val FIFO = T[FifoCache] - - /** Soft Reference: Removes objects based on the garbage collector state and the rules of Soft References. */ - val SOFT = T[SoftCache] - - /** Weak Reference: More aggressively than Soft, removes objects based on the garbage collector state and rules of Weak References. */ - val WEAK = T[WeakCache] - - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Configuration.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Configuration.scala deleted file mode 100644 index f44102c7..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Configuration.scala +++ /dev/null @@ -1,365 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -import org.apache.ibatis.session.{ Configuration => MBConfig, SqlSessionFactoryBuilder } -import org.apache.ibatis.builder.xml.XMLConfigBuilder -import java.io.Reader -import org.apache.ibatis.io.Resources -import org.mybatis.scala.session.SessionManager -import java.util.Properties -import org.mybatis.scala.mapping.Statement -import org.mybatis.scala.mapping.T -import org.mybatis.scala.cache._ -import org.apache.ibatis.`type`.TypeHandler - -/** - * Mybatis Configuration - * @constructor Creates a new Configuration with a wrapped myBatis Configuration. - * @param configuration A myBatis Configuration instance. - */ -sealed class Configuration(private val configuration: MBConfig) { - - if (configuration.getObjectFactory().getClass == classOf[org.apache.ibatis.reflection.factory.DefaultObjectFactory]) { - configuration.setObjectFactory(new DefaultObjectFactory()) - } - - if (configuration.getObjectWrapperFactory.getClass == classOf[org.apache.ibatis.reflection.wrapper.DefaultObjectWrapperFactory]) { - configuration.setObjectWrapperFactory(new DefaultObjectWrapperFactory()) - } - - registerCommonOptionTypeHandlers - - lazy val defaultSpace = new ConfigurationSpace(configuration, "_DEFAULT_") - - /** - * Creates a new space of mapped statements. - * @param name A Speca name (a.k.a. namespace) - * @param f A configuration block. - */ - def addSpace(name: String)(f: (ConfigurationSpace => Unit)): this.type = { - val space = new ConfigurationSpace(configuration, name) - f(space) - this - } - - /** Adds a statement to the default space */ - def +=(s: Statement) = defaultSpace += s - - /** Adds a sequence of statements to the default space */ - def ++=(ss: Seq[Statement]) = defaultSpace ++= ss - - /** Adds a mapper to the space */ - def ++=(mapper: { def bind: Seq[Statement] }) = defaultSpace ++= mapper - - /** - * Adds cache support to this space. - * @param impl Cache implementation class - * @param eviction cache eviction policy (LRU,FIFO,WEAK,SOFT) - * @param flushInterval any positive integer in milliseconds. - * The default is not set, thus no flush interval is used and the cache is only flushed by calls to statements. - * @param size max number of objects that can live in the cache. Default is 1024 - * @param readWrite A read-only cache will return the same instance of the cached object to all callers. - * Thus such objects should not be modified. This offers a significant performance advantage though. - * A read-write cache will return a copy (via serialization) of the cached object, - * this is slower, but safer, and thus the default is true. - * @param props implementation specific properties. - */ - def cache( - impl: T[_ <: Cache] = DefaultCache, - eviction: T[_ <: Cache] = Eviction.LRU, - flushInterval: Long = -1, - size: Int = -1, - readWrite: Boolean = true, - blocking : Boolean = false, - props: Properties = null) = - defaultSpace.cache(impl, eviction, flushInterval, size, readWrite, blocking, props) - - /** Reference to an external Cache */ - def cacheRef(that: ConfigurationSpace) = defaultSpace.cacheRef(that) - - /** Builds a Session Manager */ - def createPersistenceContext = { - val builder = new SqlSessionFactoryBuilder - new SessionManager(builder.build(configuration)) - } - - private def registerOptionTypeHandler[T <: Option[_]](h: TypeHandler[T], jdbcTypes: Seq[org.apache.ibatis.`type`.JdbcType]) = { - import org.mybatis.scala.mapping.OptionTypeHandler - val registry = configuration.getTypeHandlerRegistry - val cls = classOf[Option[_]] - for (jdbcType <- jdbcTypes) { - registry.register(cls, jdbcType, h) - } - } - - private def registerCommonOptionTypeHandlers = { - import org.mybatis.scala.mapping.OptionTypeHandler - import org.mybatis.scala.mapping.TypeHandlers._ - import org.apache.ibatis.`type`._ - import org.apache.ibatis.`type`.JdbcType._ - registerOptionTypeHandler(new OptBooleanTypeHandler(), Seq(BOOLEAN, BIT)) - registerOptionTypeHandler(new OptByteTypeHandler(), Seq(TINYINT)) - registerOptionTypeHandler(new OptShortTypeHandler(), Seq(SMALLINT)) - registerOptionTypeHandler(new OptIntegerTypeHandler(), Seq(INTEGER)) - registerOptionTypeHandler(new OptFloatTypeHandler(), Seq(FLOAT)) - registerOptionTypeHandler(new OptDoubleTypeHandler(), Seq(DOUBLE)) - registerOptionTypeHandler(new OptLongTypeHandler(), Seq(BIGINT)) - registerOptionTypeHandler(new OptStringTypeHandler(), Seq(VARCHAR, CHAR)) - registerOptionTypeHandler(new OptClobTypeHandler(), Seq(CLOB, LONGVARCHAR)) - registerOptionTypeHandler(new OptNStringTypeHandler(), Seq(NVARCHAR, NCHAR)) - registerOptionTypeHandler(new OptNClobTypeHandler(), Seq(NCLOB)) - registerOptionTypeHandler(new OptBigDecimalTypeHandler(), Seq(REAL, DECIMAL, NUMERIC)) - registerOptionTypeHandler(new OptBlobTypeHandler(), Seq(BLOB, LONGVARBINARY)) - registerOptionTypeHandler(new OptDateTypeHandler(), Seq(DATE)) - registerOptionTypeHandler(new OptTimeTypeHandler(), Seq(TIME)) - registerOptionTypeHandler(new OptTimestampTypeHandler(), Seq(TIMESTAMP)) - registerOptionTypeHandler(new OptionTypeHandler(new UnknownTypeHandler(configuration.getTypeHandlerRegistry)), Seq(OTHER)) - } - -} - -/** A factory of [[org.mybatis.scala.config.Configuration]] instances. */ -object Configuration { - - /** - * Creates a Configuration built from a reader. - * @param reader Reader over a myBatis main configuration XML - */ - def apply(reader: Reader): Configuration = { - val builder = new XMLConfigBuilder(reader) - new Configuration(builder.parse) - } - - /** - * Creates a Configuration built from a reader. - * @param reader Reader over a myBatis main configuration XML - * @param env Environment name - */ - def apply(reader: Reader, env: String): Configuration = { - val builder = new XMLConfigBuilder(reader, env) - new Configuration(builder.parse) - } - - /** - * Creates a Configuration built from a reader. - * @param reader Reader over a myBatis main configuration XML - * @param env Environment name - * @param properties Properties - */ - def apply(reader: Reader, env: String, properties: Properties): Configuration = { - val builder = new XMLConfigBuilder(reader, env, properties) - new Configuration(builder.parse) - } - - /** - * Creates a Configuration built from a classpath resource. - * @param path Classpath resource with main configuration XML - */ - def apply(path: String): Configuration = { - apply(Resources.getResourceAsReader(path)) - } - - /** - * Creates a Configuration built from a classpath resource. - * @param path Classpath resource with main configuration XML - * @param env Environment name - */ - def apply(path: String, env: String): Configuration = { - apply(Resources.getResourceAsReader(path), env) - } - - /** - * Creates a Configuration built from a classpath resource. - * @param path Classpath resource with main configuration XML - * @param env Environment name - * @param properties Properties - */ - def apply(path: String, env: String, properties: Properties): Configuration = { - apply(Resources.getResourceAsReader(path), env, properties) - } - - /** - * Creates a Configuration built from an environment - * @param env Environment - */ - def apply(env: Environment): Configuration = { - new Configuration(new MBConfig(env.unwrap)) - } - - /** - * Creates a Configuration built from a custom builder - * @param builder Builder => Unit - */ - def apply(builder: Builder): Configuration = builder.build() - - /** Configuration builder */ - class Builder { - - import org.mybatis.scala.mapping.JdbcType - import org.apache.ibatis.plugin.Interceptor - import scala.collection.mutable.ArrayBuffer - import org.mybatis.scala.session.ExecutorType - import scala.jdk.CollectionConverters._ - import org.apache.ibatis.mapping.Environment - - /** Reference to self. Support for operational notation. */ - protected val >> = this - - /** Mutable hidden state, discarded after construction */ - private val pre = new ArrayBuffer[ConfigElem[MBConfig]]() - - /** Mutable hidden state, discarded after construction */ - private val pos = new ArrayBuffer[ConfigElem[Configuration]]() - - /** Configuration Element */ - private abstract class ConfigElem[T] { - val index: Int - def set(config: T): Unit - } - - /** Ordered deferred setter */ - private def set[A](i: Int, e: ArrayBuffer[ConfigElem[A]])(f: A => Unit): Unit = { - e += new ConfigElem[A] { - val index = i - def set(c: A) = f(c) - } - } - - /** Builds the configuration object */ - private[Configuration] def build(): Configuration = { - val preConfig = new MBConfig() - pre.sortWith((a, b) => a.index < b.index).foreach(_.set(preConfig)) - val config = new Configuration(preConfig) - pos.sortWith((a, b) => a.index < b.index).foreach(_.set(config)) - config - } - - // Pre ==================================================================== - - def properties(props: (String, String)*) = - set(0, pre) { _.getVariables.asScala ++= Map(props: _*) } - - def properties(props: Properties) = - set(1, pre) { _.getVariables.asScala ++= props.asScala } - - def properties(resource: String) = - set(2, pre) { _.getVariables.asScala ++= Resources.getResourceAsProperties(resource).asScala } - - def propertiesFromUrl(url: String) = - set(3, pre) { _.getVariables.asScala ++= Resources.getUrlAsProperties(url).asScala } - - def plugin(plugin: Interceptor) = - set(4, pre) { _.addInterceptor(plugin) } - - def objectFactory(factory: ObjectFactory) = - set(5, pre) { _.setObjectFactory(factory) } - - def objectWrapperFactory(factory: ObjectWrapperFactory) = - set(6, pre) { _.setObjectWrapperFactory(factory) } - - // Settings =============== - - def autoMappingBehavior(behavior: AutoMappingBehavior) = - set(8, pre) { _.setAutoMappingBehavior(behavior.unwrap) } - - def cacheSupport(enabled: Boolean) = - set(9, pre) { _.setCacheEnabled(enabled) } - - def lazyLoadingSupport(enabled: Boolean) = - set(10, pre) { _.setLazyLoadingEnabled(enabled) } - - def aggressiveLazyLoading(enabled: Boolean) = - set(11, pre) { _.setAggressiveLazyLoading(enabled) } - - def multipleResultSetsSupport(enabled: Boolean) = - set(12, pre) { _.setMultipleResultSetsEnabled(enabled) } - - def useColumnLabel(enabled: Boolean) = - set(13, pre) { _.setUseColumnLabel(enabled) } - - def useGeneratedKeys(enabled: Boolean) = - set(14, pre) { _.setUseGeneratedKeys(enabled) } - - def defaultExecutorType(executorType: ExecutorType) = - set(15, pre) { _.setDefaultExecutorType(executorType.unwrap) } - - def defaultStatementTimeout(timeout: Int) = - set(16, pre) { _.setDefaultStatementTimeout(timeout) } - - def mapUnderscoreToCamelCase(enabled: Boolean) = - set(17, pre) { _.setMapUnderscoreToCamelCase(enabled) } - - def safeRowBoundsSupport(enabled: Boolean) = - set(18, pre) { _.setSafeRowBoundsEnabled(enabled) } - - def localCacheScope(localCacheScope: LocalCacheScope) = - set(19, pre) { _.setLocalCacheScope(localCacheScope.unwrap) } - - def jdbcTypeForNull(jdbcType: JdbcType) = - set(20, pre) { _.setJdbcTypeForNull(jdbcType.unwrap) } - - def lazyLoadTriggerMethods(names: Set[String]) = - set(21, pre) { _.setLazyLoadTriggerMethods(names.asJava) } - - def environment(id: String, transactionFactory: TransactionFactory, dataSource: javax.sql.DataSource) = - set(24, pre) { _.setEnvironment(new Environment(id, transactionFactory, dataSource)) } - - def databaseIdProvider(provider: DatabaseIdProvider) = - set(25, pre) { c => c.setDatabaseId(provider.getDatabaseId(c.getEnvironment.getDataSource)) } - - def typeHandler(jdbcType: JdbcType, handler: (T[_], TypeHandler[_])) = - set(26, pre) { _.getTypeHandlerRegistry.register(handler._1.raw, jdbcType.unwrap, handler._2) } - - def typeHandler(handler: (T[_], TypeHandler[_])) = - set(26, pre) { _.getTypeHandlerRegistry.register(handler._1.raw, handler._2) } - - def typeHandler(handler: TypeHandler[_]) = - set(26, pre) { _.getTypeHandlerRegistry.register(handler) } - - // Pos =========================================================== - - def namespace(name: String)(f: (ConfigurationSpace => Unit)) = - set(0, pos) { c => f(new ConfigurationSpace(c.configuration, name)) } - - def statements(s: Statement*) = - set(1, pos) { _ ++= s } - - def mappers(mappers: { def bind: Seq[Statement] }*) = - set(1, pos) { c => mappers.foreach(c ++= _) } - - def cacheRef(that: ConfigurationSpace) = - set(2, pos) { _.cacheRef(that) } - - def cache( - impl: T[_ <: Cache] = DefaultCache, - eviction: T[_ <: Cache] = Eviction.LRU, - flushInterval: Long = -1, - size: Int = -1, - readWrite: Boolean = true, - blocking : Boolean = false, - props: Properties = null) = - set(2, pos) { _.cache(impl, eviction, flushInterval, size, readWrite, blocking, props) } - - // PENDING FOR mybatis 3.1.1+ ================================================== - - // TODO (3.1.1) def proxyFactory(factory: ProxyFactory) = set( 7, pre) { _.setProxyFactory(factory) } - // TODO (3.1.1) def safeResultHandlerSupport(enabled : Boolean) = set(22, pre) { _.setSafeResultHandlerEnabled(enabled) } - // TODO (3.1.1) def defaultScriptingLanguage(driver : T[_]) = set(23, pre) { _.setDefaultScriptingLanguage(driver) } - - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationException.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationException.scala deleted file mode 100644 index e7e7a658..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationException.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -class ConfigurationException(msg : String, cause : Throwable = null) extends Throwable(msg, cause) { - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationSpace.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationSpace.scala deleted file mode 100644 index 6308e15a..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ConfigurationSpace.scala +++ /dev/null @@ -1,359 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -import org.apache.ibatis.session.{Configuration => MBConfig} -import org.apache.ibatis.executor.keygen.{Jdbc3KeyGenerator, NoKeyGenerator, SelectKeyGenerator, KeyGenerator => MBKeyGenerator} -import org.apache.ibatis.builder.MapperBuilderAssistant -import org.mybatis.scala.mapping._ -import org.mybatis.scala.cache._ -import java.util.ArrayList -import org.apache.ibatis.mapping.{ResultMapping => MBResultMapping, SqlSource, SqlCommandType, Discriminator} -import java.util.Properties -//eliminate a feature warning, might be a good idea to define and use traits instead of using structural types -import scala.language.reflectiveCalls - -/** Configuration Space (mybatis namespace) - * @constructor Creates an empty configuration space. - * @param configuration myBatis Configuration target - * @param spaceName Space name or namespace - */ -class ConfigurationSpace(configuration : MBConfig, val spaceName : String = "_DEFAULT_") { - - // == Start primary constructor code === - - private val builderAssistant = new MapperBuilderAssistant(configuration, spaceName) - - builderAssistant.setCurrentNamespace(spaceName) - - // == End Primary constructor code === - - // == Start of public API === - - /** Adds a statement to the space */ - def += (s : Statement) : this.type = addStatement(s) - - /** Adds a sequence of statements to the space */ - def ++=(ss : Seq[Statement]) : this.type = { - for (s <- ss) addStatement(s) - this - } - - /** Adds a mapper to the space */ - def ++=(mapper : { def bind : Seq[Statement] }) : this.type = ++=(mapper.bind) - - /** Adds cache support to this space. - * @param impl Cache implementation class - * @param eviction cache eviction policy (LRU,FIFO,WEAK,SOFT) - * @param flushInterval any positive integer in milliseconds. - * The default is not set, thus no flush interval is used and the cache is only flushed by calls to statements. - * @param size max number of objects that can live in the cache. Default is 1024 - * @param readWrite A read-only cache will return the same instance of the cached object to all callers. - * Thus such objects should not be modified. This offers a significant performance advantage though. - * A read-write cache will return a copy (via serialization) of the cached object, - * this is slower, but safer, and thus the default is true. - * @param props implementation specific properties. - */ - def cache( - impl : T[_ <: Cache] = DefaultCache, - eviction : T[_ <: Cache] = Eviction.LRU, - flushInterval : Long = -1, - size : Int = -1, - readWrite : Boolean = true, - blocking : Boolean = false, - props : Properties = null) : this.type = { - - builderAssistant.useNewCache( - impl.unwrap, - eviction.unwrap, - if (flushInterval > -1) flushInterval else null, - if (size > -1) size else null, - readWrite, - blocking, - props - ) - this - } - - /** Reference to an external Cache */ - def cacheRef(that : ConfigurationSpace) : this.type = { - builderAssistant.useCacheRef(that.spaceName) - this - } - - // == End of public API === - - private def addResultMap(rm : ResultMap[_]) : Unit = { - if (rm.fqi == null) { - rm.fqi = ConfigurationSpace.generateFQI(spaceName, rm) - if (rm.parent != null) addResultMap(rm.parent) - val resultMappings = new ArrayList[MBResultMapping] - - // Mappings - for (r <- rm.constructor ++ rm.mappings) { - if (r.nestedSelect != null) addStatement(r.nestedSelect) - if (r.nestedResultMap != null) addResultMap(r.nestedResultMap) - resultMappings add - builderAssistant.buildResultMapping( - r.resultTypeClass, - r.property, - r.column, - r.javaTypeClass, - r.jdbcTypeEnum, - resolveFQI(r.nestedSelect), - resolveFQI(r.nestedResultMap), - r.notNullColumn, - r.columnPrefix, - r.typeHandlerClass, - r.flags - ) - } - - // Discriminator - import java.util.HashMap - var discriminator : Discriminator = null - rm.discr match { - case (column, javaType, jdbcType, typeHandler, cases) => - val discriminatorMap = new HashMap[String,String] - for (c <- cases) { - addResultMap(c.resultMap) - discriminatorMap.put(c.value, c.resultMap.fqi.resolveIn(spaceName)) - } - discriminator = builderAssistant.buildDiscriminator( - rm.resultTypeClass, - column, - if (javaType == null || javaType.isVoid) classOf[String] else javaType.unwrap, - if (jdbcType == null || jdbcType == JdbcType.UNDEFINED) null else jdbcType.unwrap, - if (typeHandler == null) null else typeHandler.unwrap, - discriminatorMap - ) - case _ => - // Skip - } - - // Assemble - builderAssistant.addResultMap( - rm.fqi.id, - rm.resultTypeClass, - if (rm.parent != null) rm.parent.fqi.id else null, - discriminator, - resultMappings, - rm.autoMapping.value - ) - - } - } - - private def resolveFQI(r : { def fqi : FQI}) : String = { - if (r == null) null else r.fqi resolveIn spaceName - } - - private def addStatement(statement : Statement) : this.type = { - if (statement.fqi == null) { - statement.fqi = ConfigurationSpace.generateFQI(spaceName, statement) - statement match { - case stmt : Select => - if (stmt.resultMap != null) addResultMap(stmt.resultMap) - builderAssistant.addMappedStatement( - stmt.fqi.resolveIn(spaceName), - buildDynamicSQL(stmt.xsql), - stmt.statementType.unwrap, - SqlCommandType.SELECT, - if (stmt.fetchSize > 0) stmt.fetchSize else null, - if (stmt.timeout > -1) stmt.timeout else null, - null, - stmt.parameterTypeClass, - resolveFQI(stmt.resultMap), - stmt.resultTypeClass, - stmt.resultSetType.unwrap, - stmt.flushCache, - stmt.useCache, - false, // TODO Issue #577 - new NoKeyGenerator(), - null, - null, - stmt.databaseId, - DefaultScriptingDriver - ) - case stmt : Insert[_] => - builderAssistant.addMappedStatement( - stmt.fqi.resolveIn(spaceName), - buildDynamicSQL(stmt.xsql), - stmt.statementType.unwrap, - SqlCommandType.INSERT, - null, - if (stmt.timeout > -1) stmt.timeout else null, - null, - stmt.parameterTypeClass, - null, - classOf[Int], - ResultSetType.FORWARD_ONLY.unwrap, - stmt.flushCache, - false, - false, // TODO Issue #577 - buildKeyGenerator(stmt.keyGenerator, stmt.parameterTypeClass, stmt.fqi.id, stmt.databaseId), - if (stmt.keyGenerator == null) null else stmt.keyGenerator.keyProperty, - if (stmt.keyGenerator == null) null else stmt.keyGenerator.keyColumn, - stmt.databaseId, - DefaultScriptingDriver - ) - case stmt : Update[_] => - builderAssistant.addMappedStatement( - stmt.fqi.resolveIn(spaceName), - buildDynamicSQL(stmt.xsql), - stmt.statementType.unwrap, - SqlCommandType.UPDATE, - null, - if (stmt.timeout > -1) stmt.timeout else null, - null, - stmt.parameterTypeClass, - null, - classOf[Int], - ResultSetType.FORWARD_ONLY.unwrap, - stmt.flushCache, - false, - false, // TODO Issue #577 - new NoKeyGenerator(), - null, - null, - stmt.databaseId, - DefaultScriptingDriver - ) - case stmt : Delete[_] => - builderAssistant.addMappedStatement( - stmt.fqi.resolveIn(spaceName), - buildDynamicSQL(stmt.xsql), - stmt.statementType.unwrap, - SqlCommandType.DELETE, - null, - if (stmt.timeout > -1) stmt.timeout else null, - null, - stmt.parameterTypeClass, - null, - classOf[Int], - ResultSetType.FORWARD_ONLY.unwrap, - stmt.flushCache, - false, - false, // TODO Issue #577 - new NoKeyGenerator(), - null, - null, - stmt.databaseId, - DefaultScriptingDriver - ) - case stmt : Perform => - builderAssistant.addMappedStatement( - stmt.fqi.resolveIn(spaceName), - buildDynamicSQL(stmt.xsql), - stmt.statementType.unwrap, - SqlCommandType.UPDATE, - null, - if (stmt.timeout > -1) stmt.timeout else null, - null, - stmt.parameterTypeClass, - null, - classOf[Int], - ResultSetType.FORWARD_ONLY.unwrap, - stmt.flushCache, - false, - false, // TODO Issue #577 - new NoKeyGenerator(), - null, - null, - stmt.databaseId, - DefaultScriptingDriver - ) - case unsupported => - throw new ConfigurationException("Unsupported statement type") - //error("Unsupported statement type") - } - } - this - } - - private def buildDynamicSQL(xsql : XSQL) : SqlSource - = new DynamicSQLBuilder(configuration, xsql).build - - private def buildKeyGenerator(generator : KeyGenerator, parameterTypeClass : Class[_], baseId : String, databaseId : String) : MBKeyGenerator = { - generator match { - case jdbc : JdbcGeneratedKey => - new Jdbc3KeyGenerator() - case sql : SqlGeneratedKey[_] => - buildSqlKeyGenerator(sql, parameterTypeClass, baseId, databaseId) - case _ => - new NoKeyGenerator() - } - } - - private def buildSqlKeyGenerator(generator : SqlGeneratedKey[_], parameterTypeClass : Class[_], baseId : String, databaseId : String) : MBKeyGenerator = { - - val id = baseId + SelectKeyGenerator.SELECT_KEY_SUFFIX - val useCache = false - val keyGenerator = new NoKeyGenerator() - val fetchSize = null - val timeout = null - val flushCache = false - val parameterMap = null - val resultMap = null - val resultSetTypeEnum = null - val sqlSource = buildDynamicSQL(generator.xsql) - val sqlCommandType = SqlCommandType.SELECT - val statementType = generator.statementType.unwrap - val keyProperty = generator.keyProperty - val keyColumn = generator.keyColumn - val executeBefore = generator.executeBefore - val resultTypeClass = generator.resultTypeClass - - builderAssistant.addMappedStatement( - id, - sqlSource, - statementType, - sqlCommandType, - fetchSize, - timeout, - parameterMap, - parameterTypeClass, - resultMap, - resultTypeClass, - resultSetTypeEnum, - flushCache, - useCache, - false, // TODO Issue #577 - keyGenerator, - keyProperty, - keyColumn, - databaseId, - DefaultScriptingDriver) - - val keyStatement = configuration.getMappedStatement(id, false) - val answer = new SelectKeyGenerator(keyStatement, executeBefore) - - configuration.addKeyGenerator(id, answer) - answer - } - -} - -private object ConfigurationSpace { - - private var count : Int = 0 - - private[config] def generateFQI(spaceId : String, subject : AnyRef) = { - count += 1 - FQI(spaceId, subject.getClass.getName.replace('.', '-') + "-" + count) - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DefaultScriptingDriver.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DefaultScriptingDriver.scala deleted file mode 100644 index b7b4df37..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DefaultScriptingDriver.scala +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -object DefaultScriptingDriver extends org.apache.ibatis.scripting.xmltags.XMLLanguageDriver diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DynamicSQLBuilder.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DynamicSQLBuilder.scala deleted file mode 100644 index fccb4922..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/DynamicSQLBuilder.scala +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -import org.apache.ibatis.session.{Configuration => MBConfig} -import java.util.{List, ArrayList} -import org.apache.ibatis.scripting.xmltags._ -import org.apache.ibatis.mapping.SqlSource -import scala.xml._ - -/** Builder of Dynamic SQL Trees. */ -private[scala] class DynamicSQLBuilder(val configuration : MBConfig, val node : Node) { - - /** SqlSource built from an XML Node */ - def build : SqlSource = - new DynamicSqlSource(configuration, parse(node)) - - private def parse(n : Node) : SqlNode = { - n match { - case Text(text) => - new TextSqlNode(text) - case PCData(text) => - new TextSqlNode(text) - case {children @ _*} => - parseChildren(children) - case trim @ {children @ _*} => - val content = parseChildren(children) - new TrimSqlNode( - configuration, - content, - attr(trim, "@prefix"), - attr(trim, "@prefixOverrides"), - attr(trim, "@suffix"), - attr(trim, "@suffixOverrides") - ) - case {children @ _*} => - val content = parseChildren(children) - new WhereSqlNode(configuration, content) - case {children @ _*} => - val content = parseChildren(children) - new SetSqlNode(configuration, content) - case foreach @ {children @ _*} => - val content = parseChildren(children) - new ForEachSqlNode( - configuration, - content, - attr(foreach, "@collection"), - attr(foreach, "@index"), - attr(foreach, "@item"), - attr(foreach, "@open"), - attr(foreach, "@close"), - attr(foreach, "@separator")) - case ifNode @ {children @ _*} => - val content = parseChildren(children) - new IfSqlNode(content, attr(ifNode, "@test")) - case {children @ _*} => - val ifNodes = new ArrayList[SqlNode] - var defaultNode : MixedSqlNode = null - for (child <- children) { - child match { - case when @ {ch @ _*} => { - val content = parseChildren(ch) - ifNodes add new IfSqlNode(content, attr(when, "@test")) - } - case other @ {ch @ _*} => - if (defaultNode == null) - defaultNode = parseChildren(ch) - else - throw new ConfigurationException("Too many default (otherwise) elements in choose statement.") - //error("Too many default (otherwise) elements in choose statement.") - case _ => - } - } - new ChooseSqlNode(ifNodes, defaultNode) - case ifNode @ {children @ _*} => - val content = parseChildren(children) - new IfSqlNode(content, attr(ifNode, "@test")) - case other @ {children @ _*} => - parseChildren(other) - case a : Atom[_] => - new TextSqlNode(a.data.asInstanceOf[String]) - case bind @ => - new VarDeclSqlNode(attr(bind, "@name"), attr(bind, "@value")) - case unsupported => - throw new ConfigurationException("Unknown element " + unsupported.getClass.getName + " in SQL statement.") - //error("Unknown element " + unsupported.toString + " in SQL statement.") - } - } - - private def parseChildren(children : Seq[Node]) : MixedSqlNode = { - val nodes = new ArrayList[SqlNode] - for (child <- children) { - nodes add parse(child) - } - new MixedSqlNode(nodes) - } - - private def attr(n : Node, name : String) : String = { - (n \ name).text match { - case "" => null - case text => text - } - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Environment.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Environment.scala deleted file mode 100644 index 12ac0a8f..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/Environment.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -import javax.sql.DataSource - -/** - * - */ -case class Environment(id : String, tf : TransactionFactory, ds : DataSource) { - - val unwrap = new org.apache.ibatis.mapping.Environment(id, tf, ds) - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectFactory.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectFactory.scala deleted file mode 100644 index 6ef70758..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectFactory.scala +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -class DefaultObjectFactory extends ObjectFactory { - - def create[T](t : Class[T]) : T = create(t, null, null) - - def create[T](t : Class[T], constructorArgTypes : java.util.List[Class[_]], constructorArgs : java.util.List[AnyRef]) : T = { - val classToCreate = resolveInterface(t) - instantiateClass[T](classToCreate, constructorArgTypes, constructorArgs) - } - - override def setProperties(properties : java.util.Properties) : Unit = {} - - private def instantiateClass[T](t : Class[_], constructorArgTypes : java.util.List[Class[_]], constructorArgs : java.util.List[AnyRef]) : T = { - - val argTypes = { - if (constructorArgTypes != null) - constructorArgTypes.toArray[Class[_]](new Array[Class[_]](constructorArgTypes.size)) - else - null - } - - val constructor = getConstructor(t, argTypes) - - val argValues = { - if (constructorArgs != null) - constructorArgs.toArray[AnyRef](new Array[AnyRef](constructorArgs.size)) - else - null - } - - try { - if (argTypes == null || argValues == null) { - constructor.newInstance().asInstanceOf[T] - } - else { - constructor.newInstance(argValues : _*).asInstanceOf[T] - } - } - catch { - case e : Exception => - val types = { - if (argTypes == null) "" - else argTypes.map(_.getSimpleName).reduceLeft(_ + ", " + _) - } - val values = { - if (argValues == null) "" - else argValues.map(String.valueOf(_)).reduceLeft(_ + ", " + _) - } - throw new org.apache.ibatis.reflection.ReflectionException( - "Error instantiating %s with invalid types (%s) or values (%s). Cause: %s".format(t.getSimpleName, types, values, e.getMessage), e); - } - } - - private def resolveInterface[T](t : Class[T]) : Class[_] = { - // Java Collections - if (t == classOf[java.util.List[_]]) - classOf[java.util.LinkedList[_]] - else if (t == classOf[java.util.Collection[_]]) - classOf[java.util.LinkedList[_]] - else if (t == classOf[java.util.Map[_,_]]) - classOf[java.util.HashMap[_,_]] - else if (t == classOf[java.util.SortedSet[_]]) - classOf[java.util.TreeSet[_]] - else if (t == classOf[java.util.Set[_]]) - classOf[java.util.HashSet[_]] - // Scala Collections - else if (t == classOf[scala.collection.Seq[_]]) - classOf[scala.collection.mutable.ArrayBuffer[_]] - else if (t == classOf[scala.collection.Map[_,_]]) - classOf[scala.collection.mutable.HashMap[_,_]] - else if (t == classOf[scala.collection.Set[_]]) - classOf[scala.collection.mutable.HashSet[_]] - else { - t - } - } - - def isCollection[T](t : Class[T]) : Boolean = - classOf[scala.collection.Seq[_]].isAssignableFrom(t) || - classOf[scala.collection.Set[_]].isAssignableFrom(t) - - sealed class CacheKey(t : Class[_], args : Array[Class[_]]) { - - val _hc : Int = { - if (args == null) { - t.hashCode - } - else { - var code = t.hashCode - for (at <- args) { - code = code * 41 + at.hashCode - } - code - } - } - - override def hashCode = _hc - - override def equals(that : Any) = - that != null && - that.getClass == classOf[CacheKey] && - that.asInstanceOf[CacheKey]._hc == this._hc - - } - - def getConstructor(t : Class[_], args : Array[Class[_]]) : java.lang.reflect.Constructor[_] = { - try { - if (args == null) { - val constructor = t.getDeclaredConstructor() - if (!constructor.isAccessible()) { - constructor.setAccessible(true) - } - constructor - } - else { - val constructor = t.getDeclaredConstructor(args : _*) - if (!constructor.isAccessible()) { - constructor.setAccessible(true) - } - constructor - } - } - catch { - case e : Exception => - val types = { - if (args == null) "" - else args.map(_.getSimpleName).reduceLeft(_ + ", " + _) - } - throw new org.apache.ibatis.reflection.ReflectionException( - "Error instantiating %s with invalid types (%s). Cause: %s".format(t.getSimpleName, args, e.getMessage), e); - } - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectWrapperFactory.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectWrapperFactory.scala deleted file mode 100644 index 12186c7d..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/ObjectWrapperFactory.scala +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.config - -import org.apache.ibatis.reflection.MetaObject -import org.apache.ibatis.reflection.property.PropertyTokenizer -import org.apache.ibatis.reflection.factory.{ObjectFactory => XObjectFactory} - -abstract class CollectionObjectWrapper extends org.apache.ibatis.reflection.wrapper.ObjectWrapper { - def get(prop : PropertyTokenizer) : AnyRef = null - def set(prop : PropertyTokenizer, value : AnyRef) : Unit = {} - def findProperty(name : String, useCamelCaseMapping : Boolean) : String = null - def getGetterNames() : Array[String] = null - def getSetterNames() : Array[String] = null - def getSetterType(name : String) : Class[_] = null - def getGetterType(name : String) : Class[_] = null - def hasSetter(name : String) : Boolean = false - def hasGetter(name : String) : Boolean = false - def instantiatePropertyValue(name : String, prop : PropertyTokenizer, objectFactory : XObjectFactory) : MetaObject = null - def isCollection() : Boolean = true -} - -class ArrayBufferWrapper(buffer : scala.collection.mutable.ArrayBuffer[AnyRef]) extends CollectionObjectWrapper { - import scala.jdk.CollectionConverters._ - def add(element : AnyRef) : Unit = buffer append element - def addAll[E](elements : java.util.List[E]) : Unit = buffer.addAll(elements.asInstanceOf[java.util.Collection[AnyRef]].asScala) -} - -class HashSetWrapper(set : scala.collection.mutable.HashSet[AnyRef]) extends CollectionObjectWrapper { - import scala.jdk.CollectionConverters._ - def add(element : AnyRef) : Unit = set add element - def addAll[E](elements : java.util.List[E]) : Unit = set.addAll(elements.asInstanceOf[java.util.Collection[AnyRef]].asScala) -} - -class DefaultObjectWrapperFactory extends ObjectWrapperFactory { - def hasWrapperFor(obj : AnyRef) : Boolean = obj match { - case o : scala.collection.mutable.ArrayBuffer[_] => true - case o : scala.collection.mutable.HashSet[_] => true - case _ => false - } - def getWrapperFor(metaObject : MetaObject, obj : AnyRef) : org.apache.ibatis.reflection.wrapper.ObjectWrapper = obj match { - case o : scala.collection.mutable.ArrayBuffer[_] => new ArrayBufferWrapper(o.asInstanceOf[scala.collection.mutable.ArrayBuffer[AnyRef]]) - case o : scala.collection.mutable.HashSet[_] => new HashSetWrapper(o.asInstanceOf[scala.collection.mutable.HashSet[AnyRef]]) - case _ => - throw new IllegalArgumentException("Type not supported: " + obj.getClass.getSimpleName) - } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/package.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/package.scala deleted file mode 100644 index 6c5fbc41..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/config/package.scala +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -/** Provides main configuration classes. - * == Basic usage == - * Usual steps are: - * - Load the configuration from an external XML file - * - Add one or more configuration spaces with mapped statements - * - Create the persistenceContext - * - * == Code sample == - * {{{ - * val config = Configuration("META-INF/mybatis.xml") - * config.addSpace("ns") { space => - * space ++= MyDAO - * } - * val persistenceContext = config.createPersistenceContext - * }}} - * - * == Another example without external XML file and with default namespace == - * {{{ - * val config = Configuration( - * Environment( - * "default", - * new JdbcTransactionFactory(), - * new PooledDataSource( - * "org.hsqldb.jdbcDriver", - * "jdbc:hsqldb:mem:scala", - * "sa", - * "" - * ) - * ) - * ) - * config ++= MyDAO - * - * val persistenceContext = config.createPersistenceContext - * }}} - */ -package object config { - - type TransactionFactory = org.apache.ibatis.transaction.TransactionFactory - type JdbcTransactionFactory = org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory - type ManagedTransactionFactory = org.apache.ibatis.transaction.managed.ManagedTransactionFactory - - type PooledDataSource = org.apache.ibatis.datasource.pooled.PooledDataSource - type UnpooledDataSource = org.apache.ibatis.datasource.unpooled.UnpooledDataSource - type JndiDataSourceFactory = org.apache.ibatis.datasource.jndi.JndiDataSourceFactory - - type ObjectFactory = org.apache.ibatis.reflection.factory.ObjectFactory - type ObjectWrapperFactory = org.apache.ibatis.reflection.wrapper.ObjectWrapperFactory - type DatabaseIdProvider = org.apache.ibatis.mapping.DatabaseIdProvider - type LanguageDriver = org.apache.ibatis.scripting.LanguageDriver - - sealed abstract class LocalCacheScope { - val unwrap : org.apache.ibatis.session.LocalCacheScope - case object SESSION extends LocalCacheScope { val unwrap = org.apache.ibatis.session.LocalCacheScope.SESSION } - case object STATEMENT extends LocalCacheScope { val unwrap = org.apache.ibatis.session.LocalCacheScope.STATEMENT } - } - - sealed abstract class AutoMappingBehavior { - val unwrap : org.apache.ibatis.session.AutoMappingBehavior - case object FULL extends AutoMappingBehavior { val unwrap = org.apache.ibatis.session.AutoMappingBehavior.FULL } - case object NONE extends AutoMappingBehavior { val unwrap = org.apache.ibatis.session.AutoMappingBehavior.NONE } - case object PARTIAL extends AutoMappingBehavior { val unwrap = org.apache.ibatis.session.AutoMappingBehavior.PARTIAL } - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Binding.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Binding.scala deleted file mode 100644 index 4006e13c..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Binding.scala +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -sealed class ParamModeEnum(v : String) { - override def toString : String = v -} - -case object ModeIN extends ParamModeEnum("IN") -case object ModeOUT extends ParamModeEnum("OUT") -case object ModeINOUT extends ParamModeEnum("INOUT") - -/** Provides compile time checked inline parameter bindings. - * == Syntax == - * General notation - * {{{ - * {?[T](propertyName, jdbcType=DBT, typeHandler=T[TH], mode=MD, numericScale=NS, resultMap=RM)} - * }}} - * Where - * {{{ - * - T : JavaType : Type of the parameter property, Optional - * - propertyName : String : Name of the parameter property, Required - * - DBT : JdbcType : Any value of org.mybatis.scala.mapping.JdbcType, Optional - * - TH : TypeHandler : A TypeHandler implementation class, Optional - * - MD : ParamModeEnum : Any of (ModeIN, ModeOUT, ModeINOUT), Optional - * - NS : Int : Numeric Scale, Optional - * - RM : ResultMap : A ResultMap Object, Optional - * }}} - * - * Simplified Notation - * If you need to specify only the property name, you ca use this simplified notation: - * {{{ - * {propertyName?} - * }}} - * - * == Code Examples == - * {{{ - * - * SELECT * FROM person - * WHERE name = {"name"?} - * - * }}} - * - * {{{ - * - * SELECT * FROM task - * WHERE due_date = {?("date", typeHandler=T[JodaTimeTypeHandler])} - * - * }}} - * - */ -object Binding { - - /** Custom Aliased Types */ - private val valueTypes = Set("byte", "long", "short", "int", "double", "float", "boolean", - "byte[]", "long[]", "short[]", "int[]", "double[]", "float[]", "boolean[]") - - /** Custom alias translator */ - private def translate(cls : Class[_]) : String = { - if (valueTypes contains cls.getSimpleName) "_" + cls.getSimpleName - else cls.getName - } - - /** Generates an inline parameter binding */ - def ?[JavaType : Manifest] ( - property : String, - jdbcType : JdbcType = null, - jdbcTypeName : String = null, - numericScale : Int = 0, - mode : ParamModeEnum = ModeIN, - typeHandler : T[_ <: TypeHandler[_]] = null, - resultMap : ResultMap[_] = null - ) : String = { - Seq[Option[String]]( - Some(property) - ,if (jdbcType != null) Some("jdbcType=" + jdbcType.toString) else None - ,if (jdbcTypeName != null) Some("jdbcTypeName=" + jdbcTypeName) else None - ,if (numericScale != 0) Some("numericScale=" + numericScale) else None - ,if (mode != ModeIN) Some("mode=" + mode.toString) else None - ,if (typeHandler != null) Some("typeHandler=" + typeHandler.unwrap.getName) else None - ,if (resultMap != null) Some("resultMap=" + resultMap.fqi.id) else None - ,{ - val t = manifest[JavaType].runtimeClass - if (t != classOf[Nothing]) Some("javaType=" + translate(t)) else None - } - ) filter {_ match {case Some(x) => true; case None => false }} map {_.get} mkString("#{", ",", "}") - } - - /** Utility class for simplified syntax support */ - implicit class Param(property : String) { - def ? = Binding ? (property) - } - - /** Implicit conversion for simplified syntax support */ - //implicit def StringToParam(s : String) = new Param(s) - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Case.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Case.scala deleted file mode 100644 index 49632c50..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Case.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -/** A result map reference based on some discriminator value. - * @see [[org.mybatis.scala.mapping.ResultMap]] - * @param value A discriminator value - * @param resultMap A ResultMap to be used if value matches - * @version \$Revision$ - */ -case class Case(val value : String, val resultMap : ResultMap[Any]) diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Delete.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Delete.scala deleted file mode 100644 index 387b6ff3..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Delete.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.Session - -/** A mapped SQL DELETE statement. - * Basically this defines a function: (Param => Int) - * @tparam Param Input parameter type of the apply method. - * @version \$Revision$ - */ -abstract class Delete [Param : Manifest] - extends Statement - with SQLFunction1[Param,Int] { - - def parameterTypeClass = manifest[Param].runtimeClass - - /** Exceutes the SQL DELETE Statement - * @param param Input paramenter of the statement - * @param s Implicit Session - * @return number of affected rows - */ - def apply(param : Param)(implicit s : Session) : Int = - execute { s.delete(fqi.id, param) } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/FQI.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/FQI.scala deleted file mode 100644 index a3e2c933..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/FQI.scala +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -/** Fully Qualified Identifier */ -private[scala] case class FQI(spaceId : String, localId : String) { - def resolveIn(externalSpaceId : String) : String = { - if (externalSpaceId == spaceId) - localId - else - spaceId + "." + localId - } - def id = spaceId + "." + localId -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Insert.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Insert.scala deleted file mode 100644 index 9f7d19b5..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Insert.scala +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.Session - -/** A mapped SQL INSERT statement. - * Basically this defines a function: (Param => Int) - * @tparam Param Input parameter type of the apply method. - * @version \$Revision$ - */ -abstract class Insert[Param : Manifest] - extends Statement - with SQLFunction1[Param,Int] { - - /** Key Generator used to retrieve database generated keys. - * Defaults to null - */ - var keyGenerator : KeyGenerator = null //JdbcGeneratedKey(null, "id") - - def parameterTypeClass = manifest[Param].runtimeClass - - /** Exceutes the SQL INSERT Statement - * @param param Input paramenter of the statement - * @param s Implicit Session - * @return number of affected rows - */ - def apply(param : Param)(implicit s : Session) : Int = - execute { s.insert(fqi.id, param) } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/JdbcType.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/JdbcType.scala deleted file mode 100644 index b0246565..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/JdbcType.scala +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.`type`.{JdbcType => JdbcTypeEnum} - -/** A wrapper of [[org.apache.ibatis.type.JdbcType]] */ -sealed trait JdbcType { - val unwrap : JdbcTypeEnum - override def toString = unwrap.toString -} - -/** A wrapper of [[org.apache.ibatis.type.JdbcType]] values. */ -object JdbcType { - val ARRAY = new JdbcType { val unwrap = JdbcTypeEnum.ARRAY } - val BIT = new JdbcType { val unwrap = JdbcTypeEnum.BIT } - val TINYINT = new JdbcType { val unwrap = JdbcTypeEnum.TINYINT } - val SMALLINT = new JdbcType { val unwrap = JdbcTypeEnum.SMALLINT } - val INTEGER = new JdbcType { val unwrap = JdbcTypeEnum.INTEGER } - val BIGINT = new JdbcType { val unwrap = JdbcTypeEnum.BIGINT } - val FLOAT = new JdbcType { val unwrap = JdbcTypeEnum.FLOAT } - val REAL = new JdbcType { val unwrap = JdbcTypeEnum.REAL } - val DOUBLE = new JdbcType { val unwrap = JdbcTypeEnum.DOUBLE } - val NUMERIC = new JdbcType { val unwrap = JdbcTypeEnum.NUMERIC } - val DECIMAL = new JdbcType { val unwrap = JdbcTypeEnum.DECIMAL } - val CHAR = new JdbcType { val unwrap = JdbcTypeEnum.CHAR } - val VARCHAR = new JdbcType { val unwrap = JdbcTypeEnum.VARCHAR } - val LONGVARCHAR = new JdbcType { val unwrap = JdbcTypeEnum.LONGVARCHAR } - val DATE = new JdbcType { val unwrap = JdbcTypeEnum.DATE } - val TIME = new JdbcType { val unwrap = JdbcTypeEnum.TIME } - val TIMESTAMP = new JdbcType { val unwrap = JdbcTypeEnum.TIMESTAMP } - val BINARY = new JdbcType { val unwrap = JdbcTypeEnum.BINARY } - val VARBINARY = new JdbcType { val unwrap = JdbcTypeEnum.VARBINARY } - val LONGVARBINARY = new JdbcType { val unwrap = JdbcTypeEnum.LONGVARBINARY } - val NULL = new JdbcType { val unwrap = JdbcTypeEnum.NULL } - val OTHER = new JdbcType { val unwrap = JdbcTypeEnum.OTHER } - val BLOB = new JdbcType { val unwrap = JdbcTypeEnum.BLOB } - val CLOB = new JdbcType { val unwrap = JdbcTypeEnum.CLOB } - val BOOLEAN = new JdbcType { val unwrap = JdbcTypeEnum.BOOLEAN } - val CURSOR = new JdbcType { val unwrap = JdbcTypeEnum.CURSOR } - val UNDEFINED = new JdbcType { val unwrap = JdbcTypeEnum.UNDEFINED } - val NVARCHAR = new JdbcType { val unwrap = JdbcTypeEnum.NVARCHAR } - val NCHAR = new JdbcType { val unwrap = JdbcTypeEnum.NCHAR } - val NCLOB = new JdbcType { val unwrap = JdbcTypeEnum.NCLOB } - val STRUCT = new JdbcType { val unwrap = JdbcTypeEnum.STRUCT } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/KeyGenerator.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/KeyGenerator.scala deleted file mode 100644 index 5d87f988..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/KeyGenerator.scala +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -/** Abstract KeyGenerator - * This trait must be implemented by any KeyGenerator. - */ -trait KeyGenerator { - var keyProperty : String - var keyColumn : String -} - -/** JDBC 3 Key Generator implementation. - * This uses JDBC generatedKeys - * @param keyColumn Column to be read from the generated keys resultset. - * @param keyProperty Property to be set with the generated key value. - */ -class JdbcGeneratedKey(keyColumn_ : String, keyProperty_ : String) extends KeyGenerator { - var keyColumn = keyColumn_ - var keyProperty = keyProperty_ -} - -/** Factory of JdbcGeneratedKey */ -object JdbcGeneratedKey { - - /** Crteates a new JdbcGeneratedKey - * @param keyColumn Column to be read from the generated keys resultset. - * @param keyProperty Property to be set with the generated key value. - */ - def apply(keyColumn : String, keyProperty : String) : JdbcGeneratedKey = new JdbcGeneratedKey(keyColumn, keyProperty) - -} - -/** Base class to define a native SQL Key generator. - * @tparam Type result type of the generated key. - * == Sample code == - * {{{ - * keyGenerator = new SqlGeneratedKey[Long] { - * keyProperty = "myId" - * def xsql = "SELECT currval('my_sequence')" - * } - * }}} - */ -abstract class SqlGeneratedKey[Type : Manifest] extends KeyGenerator { - - /** Any one of STATEMENT, PREPARED or CALLABLE. - * This causes MyBatis to use Statement, PreparedStatement or CallableStatement respectively. - * Default: PREPARED. - */ - var statementType : StatementType = StatementType.PREPARED - - /** Property to be set. */ - var keyProperty : String = "id" - - /** Property to be set. */ - var keyColumn : String = null - - /** If true then this statement will be executed before the main statement. */ - var executeBefore : Boolean = false - - /** Returns the Class of the generated key. */ - val resultTypeClass = manifest[Type].runtimeClass - - /** Dynamic SQL CODE to be executed in order to obtain/generate the key - * == Code sample == - * {{{ - * def xsql = "SELECT currval('my_sequence')" - * }}} - */ - def xsql : XSQL - -} - diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/OptionTypeHandler.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/OptionTypeHandler.scala deleted file mode 100644 index a792d476..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/OptionTypeHandler.scala +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.`type`.{JdbcType => JdbcTypeEnum} -import java.sql.CallableStatement -import java.sql.PreparedStatement -import java.sql.ResultSet - -/** Generic scala.Option[T] TypeHandler. - * Wraps any TypeHandler[T] to support TypeHandler[Option[T]] - * == Example == - * {{{ - * class OptionIntegerTypeHandler extends OptionTypeHandler(new IntegerTypeHandler()) - * }}} - */ -class OptionTypeHandler[T](delegate : TypeHandler[T]) extends TypeHandler[Option[T]] { - - def setParameter(ps : PreparedStatement, i : Int, parameter : Option[T], jdbcType : JdbcTypeEnum) : Unit = - parameter match { - case None => delegate.setParameter(ps, i, null.asInstanceOf[T], jdbcType) - case Some(v) => delegate.setParameter(ps, i, v, jdbcType) - } - - def getResult(rs : ResultSet, columnName : String) : Option[T] = - Option{ delegate.getResult(rs, columnName) } - - def getResult(rs : ResultSet, columnIndex : Int) : Option[T] = - Option{ delegate.getResult(rs, columnIndex) } - - def getResult(cs : CallableStatement, columnIndex : Int) : Option[T] = - Option{ delegate.getResult(cs, columnIndex) } - -} - -/** Builtin Option TypeHandlers */ -object TypeHandlers { - - import org.apache.ibatis.`type`._ - - class OptBooleanTypeHandler extends OptionTypeHandler(new BooleanTypeHandler()) - class OptByteTypeHandler extends OptionTypeHandler(new ByteTypeHandler()) - class OptShortTypeHandler extends OptionTypeHandler(new ShortTypeHandler()) - class OptIntegerTypeHandler extends OptionTypeHandler(new IntegerTypeHandler()) - class OptLongTypeHandler extends OptionTypeHandler(new LongTypeHandler()) - class OptFloatTypeHandler extends OptionTypeHandler(new FloatTypeHandler()) - class OptDoubleTypeHandler extends OptionTypeHandler(new DoubleTypeHandler()) - class OptStringTypeHandler extends OptionTypeHandler(new StringTypeHandler()) - class OptClobTypeHandler extends OptionTypeHandler(new ClobTypeHandler()) - class OptBlobTypeHandler extends OptionTypeHandler(new BlobTypeHandler()) - class OptNStringTypeHandler extends OptionTypeHandler(new NStringTypeHandler()) - class OptNClobTypeHandler extends OptionTypeHandler(new NClobTypeHandler()) - class OptBigDecimalTypeHandler extends OptionTypeHandler(new BigDecimalTypeHandler()) - class OptDateTypeHandler extends OptionTypeHandler(new DateOnlyTypeHandler()) - class OptTimeTypeHandler extends OptionTypeHandler(new TimeOnlyTypeHandler()) - class OptTimestampTypeHandler extends OptionTypeHandler(new DateTypeHandler()) - -} - diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Perform.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Perform.scala deleted file mode 100644 index 9a625cf8..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Perform.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.Session - -/** A mapped SQL UPDATE statement. - * Basically this defines a function: (=> Int) - */ -abstract class Perform - extends Statement - with SQLFunction0[Int] { - - def parameterTypeClass = classOf[Nothing] - - /** Exceutes the SQL Statement - * @param s Implicit Session - * @return number of affected rows - */ - def apply()(implicit s : Session) : Int = - execute { s.update(fqi.id) } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultFlag.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultFlag.scala deleted file mode 100644 index 793c0749..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultFlag.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.mapping.{ResultFlag => ResultFlagEnum} - -private[scala] sealed trait ResultFlag { - val unwrap : ResultFlagEnum -} - -private[scala] object ResultFlag { - val ID = new ResultFlag { val unwrap = ResultFlagEnum.ID } - val CONSTRUCTOR = new ResultFlag { val unwrap = ResultFlagEnum.CONSTRUCTOR } -} - diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMap.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMap.scala deleted file mode 100644 index a3e06fee..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMap.scala +++ /dev/null @@ -1,335 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import scala.collection.mutable.ListBuffer - -sealed trait AutoMappingBehaviour { - val value : java.lang.Boolean -} - -object AutoMappingEnabled extends AutoMappingBehaviour { val value = java.lang.Boolean.TRUE } -object AutoMappingDisabled extends AutoMappingBehaviour { val value = java.lang.Boolean.FALSE } -object AutoMappingInherited extends AutoMappingBehaviour { val value = null } - -/** Defines a mapping between JDBC Results and Java/Scala Classes. - * @tparam ResultType type of the resulting object - * @param parent if defined, this resultmap will inherit mappings from parent. - */ -class ResultMap[ResultType : Manifest](val parent : ResultMap[_] = null) { - - private[scala] val mappings = new ListBuffer[ResultMapping] - private[scala] val constructor = new ListBuffer[ResultMapping] - private[scala] var discr : (String, T[_], JdbcType, T[_ <: TypeHandler[_]], Seq[Case]) = null - - var fqi : FQI = null - var autoMapping : AutoMappingBehaviour = AutoMappingInherited - - def resultTypeClass = manifest[ResultType].runtimeClass - - /** A single result mapping between a column and a property or field. - * This property will be used for comparisons. - * @param property Name of the property - * @param column name of the column - * @param javaType Type of the property - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - */ - def id( - property : String, - column : String, - javaType : T[_] = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - property, - column, - javaType, - jdbcType, - null, - null, - null, - null, - typeHandler, - Seq(ResultFlag.ID)) - - } - - /** A single result mapping between a column and a property or field. - * @param property Name of the property - * @param column name of the column - * @param javaType Type of the property - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - */ - def result( - property : String, - column : String, - javaType : T[_] = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - property, - column, - javaType, - jdbcType, - null, - null, - null, - null, - typeHandler, - Seq()) - } - - /** A single constructor argument that is part of a ConstructorArgs collection. - * This arg will be used for comparisons. - * @param column name of the column - * @param javaType Type of the property - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - */ - def idArg( - column : String = null, - javaType : T[_] = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - constructor += new ResultMapping( - T[ResultType], - null, - column, - javaType, - jdbcType, - null, - null, - null, - null, - typeHandler, - Seq(ResultFlag.CONSTRUCTOR, ResultFlag.ID)) - } - - /** A single constructor argument that is part of a ConstructorArgs collection. - * @param column name of the column - * @param javaType Type of the property - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param select Reference to an external select which will be called to obtain this value. - * @param resultMap Reference to an external resultMap which handles this value. - */ - def arg( - column : String = null, - javaType : T[_] = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - select : Select = null, - resultMap : ResultMap[_] = null, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - constructor += new ResultMapping( - T[ResultType], - null, - column, - javaType, - jdbcType, - select, - resultMap, - null, - null, - typeHandler, - Seq(ResultFlag.CONSTRUCTOR)) - } - - /** The association element deals with a “has-one” type relationship. - * An association mapping works mostly like any other result. - * You specify the target property, the column to retrieve the value from, the javaType - * of the property (which MyBatis can figure out most of the time), the jdbcType if necessary - * and a typeHandler if you want to override the retrieval of the result values. - * @param property Name of the property - * @param column name of the column - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param select Reference to an external select which will be called to obtain this value. - * @param resultMap Reference to an external resultMap which handles this value. - * @param notNullColumn Name of the column to be checked to avoid loading of empty objects. - * @tparam Type type of the associated object - */ - def association[Type : Manifest]( - property : String = null, - column : String = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - select : Select = null, - resultMap : ResultMap[_] = null, - notNullColumn : String = null, - columnPrefix : String = null, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - property, - column, - T[Type], - jdbcType, - select, - resultMap, - notNullColumn, - columnPrefix, - typeHandler, - Seq()) - - } - - /** The association element deals with a “has-one” type relationship. - * An association mapping works mostly like any other result. - * You specify the target property, the column to retrieve the value from, the javaType - * of the property (which MyBatis can figure out most of the time), the jdbcType if necessary - * and a typeHandler if you want to override the retrieval of the result values. - * @param column name of the column - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param select Reference to an external select which will be called to obtain this value. - * @param resultMap Reference to an external resultMap which handles this value. - * @param notNullColumn Name of the column to be checked to avoid loading of empty objects. - * @tparam Type type of the associated object - */ - def associationArg[Type : Manifest]( - column : String = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - select : Select = null, - resultMap : ResultMap[_] = null, - notNullColumn : String = null, - columnPrefix : String = null, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - null, - column, - T[Type], - jdbcType, - select, - resultMap, - notNullColumn, - columnPrefix, - typeHandler, - Seq(ResultFlag.CONSTRUCTOR)) - - } - - /** The collection element deals with a “has-many” type relationship. - * A collection mapping works mostly like any other result. - * You specify the target property, the column to retrieve the value from, the javaType - * of the property (which MyBatis can figure out most of the time), the jdbcType if necessary - * and a typeHandler if you want to override the retrieval of the result values. - * The collection element works almost identically to the association but for One-To_Many relationships. - * @param column name of the column - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param select Reference to an external select which will be called to obtain this value. - * @param resultMap Reference to an external resultMap which handles this value. - * @param notNullColumn Name of the column to be checked to avoid loading of empty objects. - * @tparam Type type of the associated objects - */ - def collection[Type : Manifest]( - property : String = null, - column : String = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - select : Select = null, - resultMap : ResultMap[_] = null, - notNullColumn : String = null, - columnPrefix : String = null, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - property, - column, - null /* Let's mybatis infer this */, - jdbcType, - select, - resultMap, - notNullColumn, - columnPrefix, - typeHandler, - Seq()) - - } - - /** The collection element deals with a “has-many” type relationship. - * A collection mapping works mostly like any other result. - * You specify the target property, the column to retrieve the value from, the javaType - * of the property (which MyBatis can figure out most of the time), the jdbcType if necessary - * and a typeHandler if you want to override the retrieval of the result values. - * The collection element works almost identically to the association but for One-To_Many relationships. - * @param column name of the column - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param select Reference to an external select which will be called to obtain this value. - * @param resultMap Reference to an external resultMap which handles this value. - * @param notNullColumn Name of the column to be checked to avoid loading of empty objects. - * @tparam Type type of the associated objects - */ - def collectionArg[Type : Manifest]( - column : String = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - select : Select = null, - resultMap : ResultMap[_] = null, - notNullColumn : String = null, - columnPrefix : String = null, - typeHandler : T[_ <: TypeHandler[_]] = null) = { - - mappings += new ResultMapping( - T[ResultType], - null, - column, - null /* Let's mybatis infer this */, - jdbcType, - select, - resultMap, - notNullColumn, - columnPrefix, - typeHandler, - Seq(ResultFlag.CONSTRUCTOR)) - - } - - /** Sometimes a single database query might return result sets of many different (but hopefully somewhat related) data types. - * The discriminator element was designed to deal with this situation, and others, including class inheritance hierarchies. - * The discriminator is pretty simple to understand, as it behaves much like a switch statement. - * A discriminator definition specifies column and javaType attributes. - * The column is where MyBatis will look for the value to compare. - * The javaType is required to ensure the proper kind of equality test is performed (although String would probably - * work for almost any situation). - * @param column where MyBatis will look for the value to compare. - * @param javaType required to ensure the proper kind of equality test is performed - * @param jdbcType Type of the column - * @param typeHandler Type of the handler - * @param cases A Collection of cases to be matched in order to select an appropiate ResultMap - */ - def discriminator( - column : String = null, - javaType : T[_] = null, - jdbcType : JdbcType = JdbcType.UNDEFINED, - typeHandler : T[_ <: TypeHandler[_]] = null, - cases : Seq[Case] = Seq()) = { - - discr = (column, javaType, jdbcType, typeHandler, cases) - - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMapping.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMapping.scala deleted file mode 100644 index da66d979..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultMapping.scala +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.`type`.{JdbcType => JdbcTypeEnum} -import org.apache.ibatis.mapping.{ResultFlag => ResultFlagEnum} -import java.util.{List => JList} -import scala.jdk.CollectionConverters._ - -private[scala] class ResultMapping ( - resultType : T[_], - property_ : String, - column_ : String, - javaType : T[_], - jdbcType : JdbcType, - nestedSelect_ : Select, - nestedResultMap_ : ResultMap[_], - notNullColumn_ : String, - columnPrefix_ : String, - typeHandler : T[_ <: TypeHandler[_]], - flags_ : Seq[ResultFlag] = Seq() -) { - - def resultTypeClass : Class[_] = resultType.unwrap - def property : String = property_ - def column : String = column_ - def javaTypeClass : Class[_] = if (javaType == null || javaType.isVoid) null else javaType.unwrap - def jdbcTypeEnum : JdbcTypeEnum = if (jdbcType == null || jdbcType == JdbcType.UNDEFINED) null else jdbcType.unwrap - def nestedSelect : Select = nestedSelect_ - def nestedResultMap : ResultMap[_] = nestedResultMap_ - def notNullColumn : String = notNullColumn_ - def typeHandlerClass : Class[_ <: TypeHandler[_]] = if (typeHandler == null) null else typeHandler.unwrap - def flags : JList[ResultFlagEnum] = (for (f <- flags_) yield f.unwrap).asJava - def columnPrefix = columnPrefix_ -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultSetType.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultSetType.scala deleted file mode 100644 index e605bdaa..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/ResultSetType.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.mapping.{ResultSetType => MBResultSetType} - -/** Wrapper of org.apache.ibatis.mapping.ResultSetType */ -sealed trait ResultSetType { - val unwrap : MBResultSetType -} - -/** Wrapper of org.apache.ibatis.mapping.ResultSetType values */ -object ResultSetType { - val FORWARD_ONLY = new ResultSetType { val unwrap = MBResultSetType.FORWARD_ONLY } - val SCROLL_INSENSITIVE = new ResultSetType { val unwrap = MBResultSetType.SCROLL_INSENSITIVE } - val SCROLL_SENSITIVE = new ResultSetType { val unwrap = MBResultSetType.SCROLL_SENSITIVE } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/SQLFunction.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/SQLFunction.scala deleted file mode 100644 index 7637e5af..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/SQLFunction.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.Session -import org.mybatis.scala.session.ResultContext - -trait SQLFunction0[+B] { - def apply()(implicit s : Session) : B -} - -trait SQLFunction1[-A, +B] { - def apply(a : A)(implicit s : Session) : B -} - -trait SQLFunction2[-A, -B, +C] { - def apply(a : A, b : B)(implicit s : Session) : C -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Select.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Select.scala deleted file mode 100644 index 18b88306..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Select.scala +++ /dev/null @@ -1,496 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.{Session, RowBounds, ResultHandlerDelegator, ResultContext} -import scala.collection.mutable._; -import java.util.{Map => JavaMap} -import scala.jdk.CollectionConverters._ - -/** Base class for all Select statements. - */ -sealed trait Select extends Statement { - - /** A reference to an external resultMap. - * Result maps are the most powerful feature of MyBatis, and with a good understanding of them, - * many difficult mapping cases can be solved. - */ - var resultMap : ResultMap[_] = null - - /** Any one of FORWARD_ONLY|SCROLL_SENSITIVE|SCROLL_INSENSITIVE. Default FORWARD_ONLY. */ - var resultSetType : ResultSetType = ResultSetType.FORWARD_ONLY - - /** This is a driver hint that will attempt to cause the driver to return results in batches of rows - * numbering in size equal to this setting. Default is unset (driver dependent). - */ - var fetchSize : Int = -1 - - /** Setting this to true will cause the results of this statement to be cached. - * Default: true for select statements. - */ - var useCache : Boolean = true - - flushCache = false - - def resultTypeClass : Class[_] - -} - -/** Query for a list of objects. - * - * == Details == - * This class defines a function: (=> List[Result]) - * - * == Sample code == - * {{{ - * val findAll = new SelectList[Person] { - * def xsql = "SELECT * FROM person ORDER BY name" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val list = findAll() - * ... - * } - * - * }}} - * @tparam Result retult type - */ -abstract class SelectList[Result : Manifest] - extends Select - with SQLFunction0[Seq[Result]] { - - def parameterTypeClass = classOf[Nothing] - def resultTypeClass = manifest[Result].runtimeClass - - def apply()(implicit s : Session) : Seq[Result] = - execute { s.selectList[Result](fqi.id) } - - def handle[T](callback : ResultContext[_ <: T] => Unit)(implicit s : Session) : Unit = - execute { s.select(fqi.id, new ResultHandlerDelegator[T](callback)) } - -} - -/** Query for a list of objects using the input parameter. - * - * == Details == - * This class defines a function: (Param => List[Result]) - * - * == Sample code == - * {{{ - * val findByName = new SelectListBy[String,Person] { - * def xsql = "SELECT * FROM person WHERE name LIKE #{name}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val list = findByName("John%") - * ... - * } - * - * }}} - * @tparam Param input parameter type - * @tparam Result retult type - */ -abstract class SelectListBy[Param : Manifest, Result : Manifest] - extends Select - with SQLFunction1[Param, Seq[Result]] { - - def parameterTypeClass = manifest[Param].runtimeClass - def resultTypeClass = manifest[Result].runtimeClass - - def apply(param : Param)(implicit s : Session) : Seq[Result] = - execute { s.selectList[Param,Result](fqi.id, param) } - - def handle(param : Param, callback : ResultContext[_ <: Result] => Unit)(implicit s : Session) : Unit = - execute { s.select(fqi.id, param, new ResultHandlerDelegator[Result](callback)) } - -} - -/** Query for a list of objects with RowBounds. - * - * == Details == - * This class defines a function: (RowBounds => List[Result]) - * - * == Sample code == - * {{{ - * val findAll = new SelectListPage[Person] { - * def xsql = "SELECT * FROM person ORDER BY name" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val list = findAll(RowBounds(100, 20)) - * ... - * } - * - * }}} - * @tparam Result retult type - */ -abstract class SelectListPage[Result : Manifest] - extends Select - with SQLFunction1[RowBounds,Seq[Result]] { - - def parameterTypeClass = classOf[Nothing] - def resultTypeClass = manifest[Result].runtimeClass - - def apply(rowBounds : RowBounds)(implicit s : Session) : Seq[Result] = - execute { s.selectList[Null,Result](fqi.id, null, rowBounds) } - - def handle(rowBounds : RowBounds, callback : ResultContext[_ <: Seq[Result]] => Unit)(implicit s : Session) : Unit = - execute { s.select(fqi.id, rowBounds, new ResultHandlerDelegator[Seq[Result]](callback)) } - -} - -/** Query for a list of objects with RowBounds and one input parameter. - * - * == Details == - * This class defines a function: ((Param, RowBounds) => List[Result]) - * - * == Sample code == - * {{{ - * val findByName = new SelectListPageBy[String,Person] { - * def xsql = "SELECT * FROM person WHERE name LIKE #{name}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val list = findByName("John%", RowBounds(100, 20)) - * ... - * } - * - * }}} - * @tparam Param input parameter type - * @tparam Result retult type - */ -abstract class SelectListPageBy[Param : Manifest, Result : Manifest] - extends Select - with SQLFunction2[Param, RowBounds, Seq[Result]] { - - def parameterTypeClass = manifest[Param].runtimeClass - def resultTypeClass = manifest[Result].runtimeClass - - def apply(param : Param, rowBounds : RowBounds)(implicit s : Session) : Seq[Result] = - execute { s.selectList[Param,Result](fqi.id, param, rowBounds) } - - def handle(param : Param, rowBounds : RowBounds, callback : ResultContext[_ <: Seq[Result]] => Unit)(implicit s : Session) : Unit = - execute { s.select(fqi.id, param, rowBounds, new ResultHandlerDelegator[Seq[Result]](callback)) } - -} - -/** Query for a single object. - * - * == Details == - * This class defines a function: (=> Result) - * - * == Sample code == - * {{{ - * val find = new SelectOne[Person] { - * def xsql = "SELECT * FROM person WHERE id = 1" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val p = find() - * ... - * } - * - * }}} - * @tparam Result retult type - */ -abstract class SelectOne[Result : Manifest] - extends Select - with SQLFunction0[Option[Result]] { - - def parameterTypeClass = classOf[Nothing] - def resultTypeClass = manifest[Result].runtimeClass - - def apply()(implicit s : Session) : Option[Result] = - execute { - val r = s.selectOne[Result](fqi.id); - if (r == null) None else Some(r) - } - -} - -/** Query for a single object using an input parameter. - * - * == Details == - * This class defines a function: (Param => Result) - * - * == Sample code == - * {{{ - * val find = new SelectOneBy[Int,Person] { - * def xsql = "SELECT * FROM person WHERE id = #{id}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val p = find(1) - * ... - * } - * - * }}} - * @tparam Param input parameter type - * @tparam Result retult type - */ -abstract class SelectOneBy[Param : Manifest, Result : Manifest] - extends Select - with SQLFunction1[Param, Option[Result]] { - - def parameterTypeClass = manifest[Param].runtimeClass - def resultTypeClass = manifest[Result].runtimeClass - - def apply(param : Param)(implicit s : Session) : Option[Result] = - execute { - val r = s.selectOne[Param,Result](fqi.id, param) - if (r == null) None else Some(r) - } - -} - -/** Query for a Map of objects. - * - * == Details == - * This class defines a function: (=> Map[ResultKey, ResultValue]) - * - * == Sample code == - * {{{ - * val peopleMapById = new SelectMap[Long,Person](mapKey="id") { - * def xsql = "SELECT * FROM person" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val people = peopleMapById() - * val p = people(5) - * ... - * } - * - * }}} - * @tparam ResultKey map Key type - * @tparam ResultValue map Value type - * @param mapKey Property to be used as map key - */ -abstract class SelectMap[ResultKey, ResultValue : Manifest](mapKey : String) - extends Select - with SQLFunction0[Map[ResultKey, ResultValue]] { - - def parameterTypeClass = classOf[Nothing] - def resultTypeClass = manifest[ResultValue].runtimeClass - - def apply()(implicit s : Session) : Map[ResultKey, ResultValue] = - execute { s.selectMap[ResultKey,ResultValue](fqi.id, mapKey) } - -} - -/** Query for a Map of objects using an input parameter. - * - * == Details == - * This class defines a function: (Param => Map[ResultKey, ResultValue]) - * - * == Sample code == - * {{{ - * val peopleMapById = new SelectMapBy[String,Long,Person](mapKey="id") { - * def xsql = "SELECT * FROM person WHERE name LIKE #{name}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val people = peopleMapById("John%") - * val p = people(3) - * ... - * } - * - * }}} - * @tparam Param input parameter type - * @tparam ResultKey map Key type - * @tparam ResultValue map Value type - * @param mapKey Property to be used as map key - */ -abstract class SelectMapBy[Param : Manifest, ResultKey, ResultValue : Manifest](mapKey : String) - extends Select - with SQLFunction1[Param, Map[ResultKey, ResultValue]] { - - def parameterTypeClass = manifest[Param].runtimeClass - def resultTypeClass = manifest[ResultValue].runtimeClass - - def apply(param : Param)(implicit s : Session) : Map[ResultKey, ResultValue] = - execute { s.selectMap[Param,ResultKey,ResultValue](fqi.id, param, mapKey) } - -} - -/** Query for a Map of objects with RowBounds. - * - * == Details == - * This class defines a function: (RowBounds => Map[ResultKey, ResultValue]) - * - * == Sample code == - * {{{ - * val peopleMapById = new SelectMapPage[Long,Person](mapKey="id") { - * def xsql = "SELECT * FROM person" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val people = peopleMapById(RowBounds(100,20)) - * val p = people(3) - * ... - * } - * - * }}} - * @tparam ResultKey map Key type - * @tparam ResultValue map Value type - * @param mapKey Property to be used as map key - */ -abstract class SelectMapPage[ResultKey, ResultValue : Manifest](mapKey : String) - extends Select - with SQLFunction1[RowBounds, Map[ResultKey, ResultValue]] { - - def parameterTypeClass = classOf[Nothing] - def resultTypeClass = manifest[ResultValue].runtimeClass - - def apply(rowBounds : RowBounds)(implicit s : Session) : Map[ResultKey, ResultValue] = - execute { s.selectMap[Null,ResultKey,ResultValue](fqi.id, null, mapKey, rowBounds) } - -} - -/** Query for a Map of objects with RowBounds and one input parameter. - * - * == Details == - * This class defines a function: ((Param, RowBounds) => Map[ResultKey, ResultValue]) - * - * == Sample code == - * {{{ - * val peopleMapById = new SelectMapPageBy[String,Long,Person](mapKey="id") { - * def xsql = "SELECT * FROM person WHERE name LIKE #{name}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val people = peopleMapById("John%", RowBounds(100,20)) - * val p = people(3) - * ... - * } - * - * }}} - * @tparam Param input parameter type - * @tparam ResultKey map Key type - * @tparam ResultValue map Value type - * @param mapKey Property to be used as map key - */ -abstract class SelectMapPageBy[Param : Manifest, ResultKey, ResultValue : Manifest](mapKey : String) - extends Select - with SQLFunction2[Param, RowBounds, Map[ResultKey, ResultValue]] { - - def parameterTypeClass = manifest[Param].runtimeClass - def resultTypeClass = manifest[ResultValue].runtimeClass - - def apply(param : Param, rowBounds : RowBounds)(implicit s : Session) : Map[ResultKey, ResultValue] = - execute { s.selectMap[Param,ResultKey,ResultValue](fqi.id, param, mapKey, rowBounds) } - -} - -/** Query for a single object using a map. - * - * == Details == - * This class defines a function: (Map[String, Any] => Result) - * - * == Sample code == - * {{{ - * val find = new SelectOneByMap[Person] { - * def xsql = "SELECT * FROM person WHERE age = #{age} AND name = #{name}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val p = find(Map("age" -> 25, "name" -> "Anon")) - * ... - * } - * - * }}} - * @tparam Result result type - */ -abstract class SelectOneByMap[Result : Manifest] - extends Select - with SQLFunction1[collection.Map[String, Any], Option[Result]] { - - def parameterTypeClass = manifest[JavaMap[String, Any]].runtimeClass - def resultTypeClass = manifest[Result].runtimeClass - - def apply(param : collection.Map[String, Any])(implicit s : Session) : Option[Result] = - execute { - Option(s.selectOne[JavaMap[String, Any],Result](fqi.id, param.asJava)) - } -} - -/** Query for a list of objects using map. - * - * == Details == - * This class defines a function: (Map[String, Any] => Seq[Result]) - * - * == Sample code == - * {{{ - * val findByNameAndAge = new SelectListByMap[Person] { - * def xsql = "SELECT * FROM person WHERE name LIKE #{name} AND age BETWEEN #{minAge} AND #{maxAge}" - * } - * - * // Configuration etc .. omitted .. - * - * // Then use it - * db.readOnly { - * val list = findByNameAndAge(Map("name" -> "John%", "minAge" -> 18, "maxAge" -> 25)) - * ... - * } - * - * }}} - * @tparam Result result type - */ -abstract class SelectListByMap[Result : Manifest] - extends Select - with SQLFunction1[collection.Map[String, Any], Seq[Result]] { - - def parameterTypeClass = manifest[JavaMap[String, Any]].runtimeClass - def resultTypeClass = manifest[Result].runtimeClass - - def apply(param : collection.Map[String, Any])(implicit s : Session) : Seq[Result] = - execute { s.selectList[JavaMap[String, Any],Result](fqi.id, param.asJava) } - - def handle(param : collection.Map[String, Any], callback : ResultContext[_ <: Result] => Unit)(implicit s : Session) : Unit = - execute { s.select(fqi.id, param, new ResultHandlerDelegator[Result](callback)) } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Statement.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Statement.scala deleted file mode 100644 index 4c7b68ec..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Statement.scala +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -/** Abstract SQL statement mapping. - * @version \$Revision$ - */ -trait Statement { - - /** Fully qualified identifier of the statement. - * Autogenerated by the configuration space. - */ - var fqi : FQI = null - - /** Any one of STATEMENT, PREPARED or CALLABLE. - * This causes MyBatis to use Statement, PreparedStatement or CallableStatement respectively. - * Default: PREPARED. - */ - var statementType : StatementType = StatementType.PREPARED - - /** This sets the maximum time the driver will wait for the database to return from a request, before throwing an exception. - * Default is unset (driver dependent). - */ - var timeout : Int = -1 - - /** Setting this to true will cause the cache to be flushed whenever this statement is called. - * Default: false for select statements. - */ - var flushCache : Boolean = true - - /** Vendor ID */ - var databaseId : String = null - - /** Scripting driver */ - var languageDriver = org.mybatis.scala.config.DefaultScriptingDriver - - /** Dynamic SQL definition, an xml node with root <xsql> - * == Code sample == - * As simple as an static SQL: - * {{{ - * def xsql = "SELECT * FROM mytable WHERE id = #{{id}}" - * }}} - * - * Or using dynamic tags: - * {{{ - * def xsql = - * - * SELECT * - * FROM mytable - * - * - * name like #{{name}} - * - * - * - * }}} - */ - def xsql : XSQL - - /** Returns the Class of the input parameter. */ - def parameterTypeClass : Class[_] - - def execute[A](command : => A) : A = fqi match { - case null => - throw new org.mybatis.scala.config.ConfigurationException("Unknown Statement " + this.getClass.getName) - case _ => - command - } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/StatementType.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/StatementType.scala deleted file mode 100644 index df7e6ead..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/StatementType.scala +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.apache.ibatis.mapping.{StatementType => MBStatementType} - -/** Wrapper of org.apache.ibatis.mapping.StatementType */ -sealed trait StatementType { - val unwrap : MBStatementType -} - -/** Wrapper of org.apache.ibatis.mapping.StatementType values */ -object StatementType { - val STATEMENT = new StatementType { val unwrap = MBStatementType.STATEMENT } - val PREPARED = new StatementType { val unwrap = MBStatementType.PREPARED } - val CALLABLE = new StatementType { val unwrap = MBStatementType.CALLABLE } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/T.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/T.scala deleted file mode 100644 index a8f9e9b6..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/T.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -/** Utility to wrap types with reflection capabilities via Manifest. - * Use T[MyType] instead of classOf[MyType] - * @tparam t wrapped type - */ -class T[t : Manifest] { - val raw = manifest[t].runtimeClass.asInstanceOf[Class[Any]] - val unwrap = manifest[t].runtimeClass.asInstanceOf[Class[t]] - val isVoid = unwrap == java.lang.Void.TYPE -} - -/** Syntactic sugar to support "T[MyType]" instead of new T[MyType] */ -object T { - def apply[t : Manifest] = new T[t] -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Update.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Update.scala deleted file mode 100644 index d82ebf31..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/Update.scala +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.Session - -/** A mapped SQL UPDATE statement. - * Basically this defines a function: (Param => Int) - * @tparam Param Input parameter type of the apply method. - * @version \$Revision$ - */ -abstract class Update[Param : Manifest] - extends Statement - with SQLFunction1[Param,Int] { - - def parameterTypeClass = manifest[Param].runtimeClass - - /** Exceutes the SQL UPDATE Statement - * @param param Input paramenter of the statement - * @param s Implicit Session - * @return number of affected rows - */ - def apply(param : Param)(implicit s : Session) : Int = - execute { s.update(fqi.id, param) } - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/package.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/package.scala deleted file mode 100644 index 798c0d56..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/mapping/package.scala +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.apache.ibatis.`type`.{TypeHandler => MBTypeHandler} -import scala.xml.Node -import scala.language.implicitConversions - -/** Statement and result mapping classes. - * == Code sample == - * Sample database - * {{{ - * - * CREATE TABLE people_group ( - * id_ serial, - * name_ varchar(255), - * primary key (id_) - * ); - * - * CREATE TABLE person ( - * id_ serial, - * first_name_ varchar(255), - * last_name_ varchar(255), - * group_id_ integer not null, - * primary key (id_), - * foreign key (group_id_) references people_group(id_) - * ); - * - * CREATE TABLE contact_info ( - * id_ serial, - * owner_id_ integer not null, - * street_address_ varchar(255), - * phone_number_ varchar(20), - * primary key (id_), - * foreign key (owner_id_) references person(id_) - * ); - * - * }}} - * - * Sample Model - * {{{ - * - * // Simple Group POJO - * class Group { - * var id : Int = _ - * var name : String = _ - * } - * - * // Simple ContactInfo POJO - * class ContactInfo { - * var id : Int = _ - * var address : String = _ - * var phone : String = _ - * } - * - * // Simple Person POJO - * class Person { - * var id : Int = _ - * var firstName : String = _ - * var lastName : String = _ - * var group : Group = _ - * var contact : java.util.List[ContactInfo] = _ - * } - * - * }}} - * - * Sample Mapping - * {{{ - * - * // Define the result mapping - * resultMap = new ResultMap[Person] { - * - * id(property="id", column="id_") - * result(property="firstName", column="first_name_") - * result(property="lastName", column="last_name_") - * - * association[Group] (property="group", column="group_id_", - * resultMap= new ResultMap[Group] { - * id(property="id", column="group_id_") - * result(property="name", column="group_name_") - * } - * ) - * - * collection[ContactInfo] (property="contact", column="cinfo_id_", - * resultMap= new ResultMap[ContactInfo] { - * id(property="id", column="cinfo_id_") - * result(property="address", column="street_address_") - * result(property="phone", column="phone_number_") - * } - * ) - * } - * }}} - */ -package object mapping { - - /** Alias of [[org.apache.ibatis.type.TypeHandler]] */ - type TypeHandler[T] = MBTypeHandler[T] - - /** Alias of [[scala.xml.Node]] */ - type XSQL = Node - - /** Implicit conversion from String to XSQL */ - implicit def string_to_xsql( s : String ) : XSQL = {s} - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ExecutorType.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ExecutorType.scala deleted file mode 100644 index f1b6a4d8..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ExecutorType.scala +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -import org.apache.ibatis.session.{ExecutorType => ET} - -sealed trait ExecutorType { - val unwrap : ET -} - -object ExecutorType { - val SIMPLE = new ExecutorType { val unwrap = ET.SIMPLE } - val REUSE = new ExecutorType { val unwrap = ET.REUSE } - val BATCH = new ExecutorType { val unwrap = ET.BATCH } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ResultHandlerDelegator.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ResultHandlerDelegator.scala deleted file mode 100644 index 34df6ca3..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/ResultHandlerDelegator.scala +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -class ResultHandlerDelegator[T](callback : ResultContext[_ <: T] => Unit) extends ResultHandler[T] { - def handleResult(context : ResultContext[_ <: T]) : Unit = callback(context) -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/RowBounds.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/RowBounds.scala deleted file mode 100644 index 46bc21c0..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/RowBounds.scala +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -/** Wrapper of [[org.apache.ibatis.session.RowBounds]] - */ -case class RowBounds(val offset: Int, val limit: Int) { - val unwrap = new org.apache.ibatis.session.RowBounds(offset, limit) -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/Session.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/Session.scala deleted file mode 100644 index f478e298..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/Session.scala +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -import org.apache.ibatis.session.SqlSession -import scala.jdk.CollectionConverters._ -import scala.collection.mutable._ - -/** SqlSession Wrapper. - * You rarely use this class in an explicit manner. - * == Usage == - * Used implicitly by mapped statements: - * {{{ - * dbcontext.transaction( implicit session => - * MyDAO.findAll() - * ) - * }}} - * @version \$Revision$ - */ -class Session(sqls : SqlSession) { - - def selectOne[Result](statement : String) : Result = { - sqls.selectOne(statement).asInstanceOf[Result] - } - - def selectOne[Param,Result](statement : String, parameter : Param) : Result = { - sqls.selectOne(statement, parameter).asInstanceOf[Result] - } - - def selectList[Result](statement : String) : Seq[Result] = { - sqls.selectList(statement).asScala.toBuffer - } - - def selectList[Param,Result](statement : String, parameter : Param) : Seq[Result] = { - sqls.selectList(statement, parameter).asScala.toBuffer - } - - def selectList[Param,Result](statement : String, parameter : Param, rowBounds : RowBounds) : Seq[Result] = { - sqls.selectList(statement, parameter, rowBounds.unwrap).asScala.toBuffer - } - - def selectMap[Key,Value](statement : String, mapKey : String) : Map[Key,Value] = { - sqls.selectMap[Key,Value](statement, mapKey).asScala - } - - def selectMap[Param,Key,Value](statement : String, parameter : Param, mapKey : String) : Map[Key,Value] = { - sqls.selectMap[Key,Value](statement, parameter, mapKey).asScala - } - - def selectMap[Param,Key,Value](statement : String, parameter : Param, mapKey : String, rowBounds : RowBounds) : Map[Key,Value] = { - sqls.selectMap[Key,Value](statement, parameter, mapKey, rowBounds.unwrap).asScala - } - - def select[Param, Res](statement : String, parameter : Param, handler : ResultHandler[Res]) : Unit = { - sqls.select(statement, parameter, handler) - } - - def select[T](statement : String, handler : ResultHandler[T]) : Unit = { - sqls.select(statement, handler) - } - - def select[Param, Res](statement : String, parameter : Param, rowBounds : RowBounds, handler : ResultHandler[Res]) : Unit = { - sqls.select(statement, parameter, rowBounds.unwrap, handler) - } - - def insert(statement : String) : Int = { - sqls.insert(statement) - } - - def insert[Param](statement : String, parameter : Param) : Int = { - sqls.insert(statement, parameter) - } - - def update(statement : String) : Int = { - sqls.update(statement) - } - - def update[Param](statement : String, parameter : Param) : Int = { - sqls.update(statement, parameter) - } - - def delete(statement : String) : Int = { - sqls.delete(statement) - } - - def delete[Param](statement : String, parameter : Param) : Int = { - sqls.delete(statement, parameter) - } - - def commit() : Unit = sqls.commit - - def commit(force : Boolean) : Unit = sqls.commit(force) - - def rollback() : Unit = sqls.rollback - - def rollback(force : Boolean) : Unit = sqls.rollback(force) - - def clearCache() : Unit = sqls.clearCache - - def flushStatements() : Seq[BatchResult] = sqls.flushStatements.asScala - -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/SessionManager.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/SessionManager.scala deleted file mode 100644 index 4d5ccbdf..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/SessionManager.scala +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -import org.apache.ibatis.logging.LogFactory -import SessionManager.log -import org.apache.ibatis.session.{SqlSession, SqlSessionFactory} - -/** Session lifecycle manager. - * Manages the lifecycle of the Session - * == Usage == - * - Rollback only - * {{{ - * sessionManager.readOnly { implicit session => - * // Your code ... - * // Always rollback at the end automatically. - * } - * }}} - * - Direct transaction - * {{{ - * sessionManager.transaction { implicit session => - * // Your code ... - * // Always commit at the end if no exceptions are thrown, else rollback. - * } - * }}} - * - External transaction - * {{{ - * sessionManager.managed { implicit session => - * // Your code ... - * // Never commit or rollback automatically. - * // The transaction can be managed externally or manually. - * } - * }}} - * - * @version \$Revision$ - */ -sealed class SessionManager(factory : SqlSessionFactory) { - - type Callback[T] = (Session) => T - type CloseSessionHook = (SqlSession) => Unit - - private var closeSession : CloseSessionHook = {(s : SqlSession) => s.close} - - def closeSessionHook(hook : CloseSessionHook) = { - closeSession = hook - } - - /** Executes the callback within a new session and rollback at the end. */ - def readOnly[T]( - executorType : ExecutorType = ExecutorType.SIMPLE, - level: TransactionIsolationLevel = TransactionIsolationLevel.UNDEFINED)(callback : Callback[T]) : T = { - val sqlSession = factory.openSession(executorType.unwrap, level.unwrap) - try { - val ret = callback(new Session(sqlSession)) - sqlSession.rollback - ret - } - finally { - closeSession(sqlSession) - } - } - - /** Executes the callback within a new session and rollback at the end. */ - def readOnly[T](callback : Callback[T]) : T = readOnly[T]()(callback) - - private def transaction[T](sqlSession : SqlSession)(callback : Callback[T]) : T = { - try { - val t = callback(new Session(sqlSession)) - sqlSession.commit - t - } - catch { - case e : Throwable => - try { - sqlSession.rollback - } - catch { - case e2 : Exception => - // Ignore. There's nothing that can be done at this point. - // Throw the original exception as that's the one that matters. - log.warn("Unexpected exception on rolling back transaction. Cause: " + e2) - throw e - } - throw e - } - finally { - closeSession(sqlSession) - } - } - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](executorType : ExecutorType, level : TransactionIsolationLevel)(callback : Callback[T]) : T = - transaction[T](factory.openSession(executorType.unwrap, level.unwrap))(callback) - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](executorType : ExecutorType)(callback : Callback[T]) : T = - transaction[T](factory.openSession(executorType.unwrap))(callback) - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](level : TransactionIsolationLevel)(callback : Callback[T]) : T = - transaction[T](factory.openSession(level.unwrap))(callback) - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](executorType : ExecutorType, autoCommit : Boolean)(callback : Callback[T]) : T = - transaction[T](factory.openSession(executorType.unwrap, autoCommit))(callback) - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](autoCommit : Boolean)(callback : Callback[T]) : T = - transaction[T](factory.openSession(autoCommit))(callback) - - /** Executes the callback within a new transaction and commit at the end, automatically calls rollback if any exception. */ - def transaction[T](callback : Callback[T]) : T = - transaction[T](ExecutorType.SIMPLE, TransactionIsolationLevel.UNDEFINED)(callback) - - /** Executes the callback within a new session. Does not call any transaction method. */ - def managed[T](executorType : ExecutorType)(callback : Callback[T]) : T = { - val sqlSession = factory.openSession(executorType.unwrap) - try { - callback(new Session(sqlSession)) - } - finally { - closeSession(sqlSession) - } - } - - /** Executes the callback within a new session. Does not call any transaction method. */ - def managed[T](callback : Callback[T]) : T = managed[T](ExecutorType.SIMPLE)(callback) - -} - -object SessionManager { - val log = LogFactory.getLog(classOf[SessionManager]) -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/TransactionIsolationLevel.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/TransactionIsolationLevel.scala deleted file mode 100644 index 140bad50..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/TransactionIsolationLevel.scala +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.session - -import org.apache.ibatis.session.{TransactionIsolationLevel => TIL} - -sealed trait TransactionIsolationLevel { - val unwrap : TIL -} - -object TransactionIsolationLevel { - val NONE = new TransactionIsolationLevel { val unwrap = TIL.NONE } - val READ_COMMITTED = new TransactionIsolationLevel { val unwrap = TIL.READ_COMMITTED } - val READ_UNCOMMITTED = new TransactionIsolationLevel { val unwrap = TIL.READ_UNCOMMITTED } - val REPEATABLE_READ = new TransactionIsolationLevel { val unwrap = TIL.REPEATABLE_READ } - val SERIALIZABLE = new TransactionIsolationLevel { val unwrap = TIL.SERIALIZABLE } - val UNDEFINED = new TransactionIsolationLevel { val unwrap = null } -} diff --git a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/package.scala b/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/package.scala deleted file mode 100644 index 63c4a9d2..00000000 --- a/mybatis-scala-core/src/main/scala/org/mybatis/scala/session/package.scala +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.apache.ibatis.session.{ResultHandler => MBResultHandler, ResultContext => MBResultContext} -import org.apache.ibatis.session.{RowBounds => MBRowBounds} - -/** Session Management classes. - * Provides classes needed to execute the mapped statements. - * == Basic usage == - * Usual steps are: - * - Obtain a SessionManager instance from a Configuration - * - Call any of the lifecycle methods of the SessionManager passing the code to be executed. - * == Code sample == - * {{{ - * val db = Config.persistenceContext - * db.transaction { implicit session => - * MyDAO.insert(...) - * MyDAO.update(...) - * // etc... - * } - * }}} - * @version \$Revision$ - */ -package object session { - - /** Alias of [[org.apache.ibatis.session.ResultHandler]] */ - type ResultHandler[T] = MBResultHandler[T] - - /** Alias of [[org.apache.ibatis.session.ResultContext]] */ - type ResultContext[T] = MBResultContext[T] - - /** Alias of [[org.apache.ibatis.executor.BatchResult]] */ - type BatchResult = org.apache.ibatis.executor.BatchResult - -} diff --git a/mybatis-scala-core/src/site/site.xml b/mybatis-scala-core/src/site/site.xml deleted file mode 100644 index 44e4d146..00000000 --- a/mybatis-scala-core/src/site/site.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - - - - - - - - diff --git a/mybatis-scala-core/src/site/xdoc/cache.xml b/mybatis-scala-core/src/site/xdoc/cache.xml deleted file mode 100644 index 95f7e63c..00000000 --- a/mybatis-scala-core/src/site/xdoc/cache.xml +++ /dev/null @@ -1,55 +0,0 @@ - - - - - - MyBatis Scala API > Cache - The MyBatis Team - $Date$ - - - -
-

This org.mybatis.scala.cache package provides some aliases to core MyBatis Cache types.

-

See the API docs for more info about caching.

-

- The only thing you have to do is call the cache method of the space, - all parameters are optional, and by default they are set to sensible values. -

- - - space cache(eviction=FIFO) - - space += findPeople - space ++= PersonDAO - space ++= Seq(deletePerson, updatePerson, ...) - - ... - -}]]> -

- Notice Call the cache method earliest in the space block. -

-
- -
diff --git a/mybatis-scala-core/src/site/xdoc/configuration.xml b/mybatis-scala-core/src/site/xdoc/configuration.xml deleted file mode 100644 index e83ad2cb..00000000 --- a/mybatis-scala-core/src/site/xdoc/configuration.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - MyBatis Scala API > Configuration - The MyBatis Team - $Date$ - - - -
-

- The main responsibility of the org.mybatis.scala.config package is to provide classes to load the - main configurations like plugins, datasource and transaction services, etc... -

-

- Because this API is code centric and type safe, you don't need typeAliases. When you need to reference a type 'Type' - just use T[Type]. -

-

- Your main configuration is specified in a small XML file as usual: - http://mybatis.org/dtd/mybatis-3-config.dtd - But you don't need to specify typeAliases nor mappers. Look at the mybatis core users guide for more details. -

-

- A sample configuration file could be: -

- - - - - - - - - - - - - - - -]]> -

- Once you have your configuration file, you can load it with the Configuration class: - -

-

- Once you have your main configuration in place, you should add one or more configuration spaces with - your mappings.

- - space += findPeople // Adds mapped statement findPeople - space ++= PersonDAO // Adds all mapped statements declared in PersonDAO - space ++= Seq(deletePerson, updatePerson, ...) // Adds all specified statements -}]]> -

- Configuration instances should be created only once per application, just like the SqlSessionFactory. -

-

- All the configuration code is disconnected, so you can put it in a static initializer (scala object) - or wherever you want. -

-
- -
diff --git a/mybatis-scala-core/src/site/xdoc/index.xml b/mybatis-scala-core/src/site/xdoc/index.xml deleted file mode 100644 index e833bef3..00000000 --- a/mybatis-scala-core/src/site/xdoc/index.xml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - MyBatis Scala API > Introduction - The MyBatis Team - $Date$ - - - -
-

Binary compatible with MyBatis-3.1.0

-
- -
-

- MyBatis is one of the best advanced persistence frameworks available for java, it can be - used with Scala too, but the main API is Java centric. This sub-project is to provide a - more scala friendly API, it does not uses any annotation, and all SQL (static and dynamic) - can be declared directly and elegantly in your scala code. -

- - -

- The API is structured in four main packages, each package contains types and objects related to a specific - concern. They are Configuration, Mapping, Session and Cache. -

-
    -
  • - Configuration package: - org.mybatis.scala.config -
  • -
  • - Mapping package: - org.mybatis.scala.mapping -
  • -
  • - Session package: - org.mybatis.scala.session -
  • -
  • - Cache package: - org.mybatis.scala.cache -
  • -
-
-
- - -
diff --git a/mybatis-scala-core/src/site/xdoc/mapping.xml b/mybatis-scala-core/src/site/xdoc/mapping.xml deleted file mode 100644 index 4365d5a9..00000000 --- a/mybatis-scala-core/src/site/xdoc/mapping.xml +++ /dev/null @@ -1,157 +0,0 @@ - - - - - - MyBatis Scala API > Mapping - The MyBatis Team - $Date$ - - - -
-

- org.mybatis.scala.mapping is the main package of the API, this provides all idioms needed to - declare ResultMaps and Statements. -

- -

- To declare a ResultMap, just extend ResultMap[T] and call its mapping methods in its main constructor.

- -

- You can define contructor args, properties, associations, collections, discriminators, ... - Look at the scaladoc for furter details of ResultMap construction. -

-

- You can declare your ResultMaps wherever you want, you will reference them later when you declare - your mapped statements. -

-
- - -

- There are four types of Mapped Statements as you know: Select, Insert, Update and Delete. But Select is - a special case with three subtypes: SelectOne, SelectList and SelectMap. -

-

- To define/declare a mapped statement you just have to extend one of the Statement types and set the - desired properties. -

-
- - -

- For example, if you want to select a User by its id: -

- SELECT * from user WHERE id = {"id"?} -} - -// this is also valid -val findUserById = new SelectOneBy[Int,User] { - def xsql = - - SELECT * - FROM user - WHERE id = {"id"?} - -}]]> -

- You can also select a list of users filtered by its name -

- - SELECT * - FROM user - WHERE name LIKE {"name"?} - -}]]> -
- - -

- The same applies to these statement types, just extends and define. -

-

- Example -

- - INSERT INTO user(name, username, password) - VALUES ({"name"?}, {"username"?}, {"password"?}) - -}]]> - -

- All the mapping code is disconnected, so you can put it in a static initializer (scala object) - or wherever you want. -

-
- -

- There are two syntaxes: Textual notation and Scala notation, lets see - -

-

Textual notation

-

- The former mybatis notation can be used here escaping '{' and '}' chars. - - SELECT * - FROM .... - WHERE field = #{{param}} - - - SELECT * - FROM .... - WHERE field = #{{param, jdbcType=VARCHAR, mode=IN}} - - In this case VARCHAR and IN are just strings that will be parsed at runtime. - -

-

-

Scala notation

-

- You can import org.mybatis.scala.mapping.Binding._ and use the ? function. It provides - type safety on binding attributes. - - SELECT * - FROM .... - WHERE field = {"param"?} - - - SELECT * - FROM .... - WHERE field = {? ("param", jdbcType=JdbcType.VARCHAR, mode=ModeIN, typeHandler=T[CustomTHandler]) } - - In this case JdbcType.VARCHAR and ModeIN are true object references and CustomTHandler is a type reference, so they will be checked at compile time. - -

-
-
- -
diff --git a/mybatis-scala-core/src/site/xdoc/session.xml b/mybatis-scala-core/src/site/xdoc/session.xml deleted file mode 100644 index 2e3c06b5..00000000 --- a/mybatis-scala-core/src/site/xdoc/session.xml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - MyBatis Scala API > Session - The MyBatis Team - $Date$ - - - -
-

- The org.mybatis.scala.session package provides service classes to execute your mapped statements - against a database connection. -

-

- The main class in this package is SessionManager which its instances are provided by the configuration - object. You should have only one instance of the SessionManager in your application. Just like - SqlSessionFactory. This class is disconnected, it only create connections when you call a connected method. -

- - -

- This method opens a connection, executes a code block, calls rollback and close. -

- - - val list = findUsers("a%") - for (user <- list) { - // Do something with user - } - -}]]> -
- - -

- This method opens a connection, executes a code block, and calls commit if no exceptions are thrown, - else calls rollback, then close. -

- - - val user = new User - user.name = "John" - user.username = "john1" - user.password = "12345" - - insertNewUser(user) - -}]]> -
- - -

- This method opens a connection, executes a code block and closes the connection. The Transaction lifecycle - must be managed externally by the container or manually by the developer. - - - val user = new User - user.name = "John" - user.username = "john1" - user.password = "12345" - - insertNewUser(user) - -}]]> -

-
-
- -
diff --git a/mybatis-scala-core/src/test/resources/mybatis.xml b/mybatis-scala-core/src/test/resources/mybatis.xml deleted file mode 100644 index b537fa36..00000000 --- a/mybatis-scala-core/src/test/resources/mybatis.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/Database.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/Database.scala deleted file mode 100644 index 34b855ec..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/Database.scala +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.mybatis.scala.config.Configuration -import org.mybatis.scala.infrastructure.{BlogRepository, UserRepository} - -/** - * Provides [[org.mybatis.scala.session.SessionManager]] instances. - */ -object Database { - val config = Configuration("mybatis.xml") - - config.addSpace("test") { space => - space ++= DatabaseSchema - space ++= UserRepository - space ++= BlogRepository - } - - /** - * A configuration intended to be used for simple tests. - */ - lazy val default = config.createPersistenceContext -} - diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSchema.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSchema.scala deleted file mode 100644 index bb9b749b..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSchema.scala +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.session.Session - -/** - * This object provides the feature of creating database tables. - */ -object DatabaseSchema { - - /** - * Prepares tables for testing. - * @param session the session object to connect to databases. - */ - def prepare(implicit session: Session): Unit = { - bind foreach { - case perform: Perform => perform() - } - } - - /** - * Creates a table containing user data. - */ - val createUserTable = new Perform { - def xsql = - - CREATE TABLE IF NOT EXISTS user( - id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL, - name VARCHAR(64) NOT NULL, - email VARCHAR(256) NOT NULL, - PRIMARY KEY (id) - ) - - } - - /** - * Creates a table containing blog data. - */ - val createBlogTable = new Perform { - def xsql = - - CREATE TABLE IF NOT EXISTS blog( - id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL, - title VARCHAR(128) NOT NULL, - PRIMARY KEY (id) - ) - - } - - /** - * Creates a table containing entries posted to blogs. - */ - val createEntryTable = new Perform { - def xsql = - - CREATE TABLE IF NOT EXISTS entry( - id INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) NOT NULL, - body BLOB NOT NULL, - blog_id INTEGER NOT NULL, - PRIMARY KEY (id) - ) - - } - - def bind = Seq(createUserTable, createBlogTable, createEntryTable) -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSupport.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSupport.scala deleted file mode 100644 index 89d10f44..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/DatabaseSupport.scala +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala - -import org.mybatis.scala.config.Configuration -import org.mybatis.scala.session.{Session, SessionManager} -import org.mybatis.scala.infrastructure.{BlogRepository, UserRepository} - -/** - * This trait provides the feature of using databases in test cases. - */ -trait DatabaseSupport { - /** - * Executes a callback function provided by a argument of this function within a read-only database transaction. - * @param block the callback function to be executed within a database transaction. - */ - def withReadOnly(db: SessionManager)(block: Session => Unit): Unit = { - db.readOnly { implicit session => - DatabaseSchema.prepare - block(session) - } - } -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/Blog.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/Blog.scala deleted file mode 100644 index 2fec71a6..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/Blog.scala +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.domain - -case class Blog(var title: String) { - var id: Int = _ - var entries: Seq[Entry] = Seq.empty -} - -object Blog { - def apply(id: Int, title: String): Blog = { - val blog = Blog(title) - blog.id = id - blog - } -} - -case class Entry(var body: String) { - var id: Int = _ -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/User.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/User.scala deleted file mode 100644 index 7eae2beb..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/domain/User.scala +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.domain - -/** - * This class provides information about an user. - * @param id the identity to specify a user - * @param name the user name - * @param email the email address - */ -case class User(var id: Int, var name: String, var email: String) diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/BlogRepository.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/BlogRepository.scala deleted file mode 100644 index 0b72340f..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/BlogRepository.scala +++ /dev/null @@ -1,249 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.infrastructure - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.mapping.Binding._ -import org.mybatis.scala.domain.{Entry, Blog} -import org.mybatis.scala.session.Session -import scala.language.postfixOps - -object BlogRepository { - lazy val blogResultMap = new ResultMap[Blog] { - id(column = "blog_id", property = "id") - arg(column = "blog_title", javaType = T[String]) - collection(property = "entries", resultMap = entryResultMap) - } - - lazy val entryResultMap = new ResultMap[Entry] { - id(column = "entry_id", property = "id") - arg(column = "entry_body", javaType = T[String]) - } - - val findFirst = new SelectOne[Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - ORDER BY b.id - LIMIT 1 - - } - - val findById = new SelectOneBy[Int, Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - WHERE - b.id = {"id" ?} - - } - - val findAll = new SelectList[Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - - } - - val findAllByTitle = new SelectListBy[String, Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - WHERE - b.title = {"title" ?} - - } - - val findAllWithPage = new SelectListPage[Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - - } - - val findAllByTitleWithPage = new SelectListPageBy[String, Blog] { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - WHERE - b.title = {"title" ?} - - } - - val findMapByTitle = new SelectMap[String, Blog](mapKey = "title") { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - - } - - val findMapByTitleWithPage = new SelectMapPage[String, Blog](mapKey = "title") { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - - } - - val findMapByTitleWithCondition = new SelectMapBy[String, String, Blog](mapKey = "title") { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - WHERE - b.title LIKE {"title" ?} - - } - - val findMapByTitleWithConditionAndPage = new SelectMapPageBy[String, String, Blog](mapKey = "title") { - resultMap = blogResultMap - def xsql = - - SELECT - b.id as blog_id, - b.title as blog_title, - e.id as entry_id, - e.body as entry_body - FROM - blog b - LEFT OUTER JOIN - entry e - ON - e.blog_id = b.id - WHERE - b.title LIKE {"title" ?} - ORDER BY b.id ASC - - } - - val insertBlog = new Insert[Blog] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = INSERT INTO blog(title) VALUES({"title" ?}) - } - - val insertEntry = new Insert[Entry] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = INSERT INTO entry(body) VALUES({"body" ?}) - } - - def create(blog: Blog)(implicit session: Session) = { - insertBlog(blog) - blog.entries.foreach(e => insertEntry(e)) - } - - def bind = Seq( - insertBlog, insertEntry, findById, findAll, findAllByTitle, - findAllWithPage, findAllByTitleWithPage, findFirst, findMapByTitle, - findMapByTitleWithCondition, findMapByTitleWithPage, findMapByTitleWithConditionAndPage - ) -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/UserRepository.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/UserRepository.scala deleted file mode 100644 index ec4e1a58..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/infrastructure/UserRepository.scala +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.infrastructure - -import org.mybatis.scala.domain.User -import org.mybatis.scala.mapping._ -import org.mybatis.scala.mapping.Binding._ -import scala.language.postfixOps - -object UserRepository { - val defaultResultMap = new ResultMap[User] { - idArg(column = "id", javaType = T[Int]) - arg(column = "name", javaType = T[String]) - arg(column = "email", javaType = T[String]) - } - - val create = new Insert[User] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = INSERT INTO user(name, email) VALUES({"name" ?}, {"email" ?}) - } - - val createFromTuple2 = new Insert[(String, String)] { - def xsql = INSERT INTO user(name, email) VALUES({"_1" ?}, {"_2" ?}) - } - - val findById = new SelectOneBy[Int, User] { - resultMap = defaultResultMap - def xsql = SELECT * FROM user WHERE id = {"id" ?} - } - - val findAll = new SelectList[User] { - resultMap = defaultResultMap - def xsql = SELECT * FROM user - } - - val lastInsertId = new SelectOne[Int] { - def xsql = CALL IDENTITY() - } - - def bind = Seq(create, createFromTuple2, findById, findAll, lastInsertId) -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/InsertSpec.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/InsertSpec.scala deleted file mode 100644 index a1439bdf..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/InsertSpec.scala +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.{Database, DatabaseSupport} -import org.mybatis.scala.domain.User -import org.mybatis.scala.infrastructure.UserRepository -import org.scalatest._ -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers - -/** - * The specification for [[Insert]]. - */ -class InsertSpec extends AnyFunSpec with Matchers with DatabaseSupport { - describe("A Insert") { - it("should insert User into user table") { - withReadOnly(Database.default) { implicit session => - val expected = User(0, "test", "example@example.com") - - UserRepository.create(expected) - - UserRepository.findById(expected.id) should equal (Some(expected)) - } - } - - it("should insert User into user table from Tuple2") { - withReadOnly(Database.default) { implicit session => - val name = "test_user" - val email = "example@example.com" - - UserRepository.createFromTuple2((name, email)) - - for { - id <- UserRepository.lastInsertId() - actual <- UserRepository.findById(id) - } yield { - val expected = User(id, name, email) - actual should equal (expected) - Some(expected) - } getOrElse fail("unable to get last insert id.") - } - } - } -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/SelectSpec.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/SelectSpec.scala deleted file mode 100644 index e21d4a15..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/SelectSpec.scala +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.session.RowBounds -import org.scalatest._ -import org.mybatis.scala.{Database, DatabaseSupport} -import org.mybatis.scala.infrastructure.BlogRepository -import org.mybatis.scala.domain.{Blog, Entry} -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers - -/** - * The specification of [[org.mybatis.scala.mapping.SelectList]]. - */ -class SelectSpec extends AnyFunSpec with Matchers with DatabaseSupport with BeforeAndAfter { - describe("selectOne") { - it("should fetch first record") { - withReadOnly(Database.default) { implicit session => - val expected = Blog("title") - BlogRepository.create(expected) - - assert(Some(expected) === BlogRepository.findFirst()) - } - } - } - - describe("selectOneBy") { - it("should fetch the record specified by the argument value") { - withReadOnly(Database.default) { implicit session => - val expected = Blog("test") - - BlogRepository.create(expected) - - assert(Some(expected) === BlogRepository.findById(expected.id)) - } - } - - it("should not fetch any record if there is no matching record in database") { - withReadOnly(Database.default) { implicit session => - assert(None === BlogRepository.findById(100)) - } - } - } - - describe("A SelectList") { - it("should return all records in database") { - withReadOnly(Database.default) { implicit session => - val totalRecords = 10 - - for (i <- 1 to totalRecords) { - BlogRepository.create(Blog(s"$i")) - } - - assert(totalRecords === BlogRepository.findAll().size) - } - } - - it("should return an empty collection if there is no record") { - withReadOnly(Database.default) { implicit session => - assert(Seq.empty[Blog] === BlogRepository.findAll()) - } - } - } - - describe("selectListBy") { - it("should return all records specified by the argument value") { - withReadOnly(Database.default) { implicit session => - val title = "title" - val totalRecords = 10 - - for (_ <- 1 to totalRecords) { - BlogRepository.create(Blog(title)) - } - - BlogRepository.create(Blog("")) - - val actual = BlogRepository.findAllByTitle(title) - - assert(totalRecords === actual.size) - - actual foreach { - case Blog(theTitle) => assert(title === theTitle) - } - } - } - - it("should return an empty collection if there is no record") { - withReadOnly(Database.default) { implicit session => - assert(Seq.empty[Blog] === BlogRepository.findAllByTitle("test")) - } - } - } - - describe("selectListPage") { - it("should fetch records by specifying the offset and limit") { - withReadOnly(Database.default) { implicit session => - for (_ <- 1 to 10) { - BlogRepository.create(Blog("title")) - } - assert(3 === BlogRepository.findAllWithPage(RowBounds(0, 3)).size) - assert(3 === BlogRepository.findAllWithPage(RowBounds(1, 3)).size) - assert(2 === BlogRepository.findAllWithPage(RowBounds(8, 3)).size) - } - } - } - - describe("selectListPageBy") { - it("should fetch records by specifying title, offset, and limit") { - withReadOnly(Database.default) { implicit session => - val title = "title" - for (_ <- 1 to 10) { - BlogRepository.create(Blog(title)) - } - assert(3 === BlogRepository.findAllByTitleWithPage(title, RowBounds(0, 3)).size) - assert(3 === BlogRepository.findAllByTitleWithPage(title, RowBounds(1, 3)).size) - assert(2 === BlogRepository.findAllByTitleWithPage(title, RowBounds(8, 3)).size) - } - } - } - - describe("selectMap") { - it("should fetch records as Map") { - withReadOnly(Database.default) { implicit session => - for (i <- 1 to 10) { - BlogRepository.create(Blog("title" + i)) - } - - val blogs = BlogRepository.findMapByTitle() - assert("title1" === blogs("title1").title) - assert("title2" === blogs("title2").title) - assert(false === blogs.contains("")) - } - } - } - - describe("selectMapBy") { - it("should fetch records which starts with new prefix as Map") { - withReadOnly(Database.default) { implicit session => - for (i <- 1 to 10) { - if (i % 2 == 0) { - BlogRepository.create(Blog("newtitle"+ i)) - } else { - BlogRepository.create(Blog("title" + i)) - } - } - - val blogs = BlogRepository.findMapByTitleWithCondition("new%") - assert(false === blogs.contains("title1")) - assert("newtitle2" === blogs("newtitle2").title) - } - } - } - - describe("selectMapPage") { - it("should fetch records as Map by specifying limit and offset") { - withReadOnly(Database.default) { implicit session => - for (i <- 1 to 10) { - BlogRepository.create(Blog("title" + i)) - } - - val blogs = BlogRepository.findMapByTitleWithPage(RowBounds(0, 3)) - assert("title1" === blogs("title1").title) - assert("title2" === blogs("title2").title) - assert("title3" === blogs("title3").title) - assert(false === blogs.contains("title4")) - } - } - } - - describe("selectMapPageBy") { - it("should fetch records as Map by specifying title, limit, and offset") { - withReadOnly(Database.default) { implicit session => - for (i <- 1 to 10) { - if (i % 2 == 0) { - BlogRepository.create(Blog("newtitle"+ i)) - } else { - BlogRepository.create(Blog("title" + i)) - } - } - - val blogs = BlogRepository.findMapByTitleWithConditionAndPage("new%", RowBounds(0, 3)) - - println(blogs) - assert("newtitle2" === blogs("newtitle2").title) - assert("newtitle4" === blogs("newtitle4").title) - assert("newtitle6" === blogs("newtitle6").title) - assert(false === blogs.contains("newtitle8")) - } - } - } -} diff --git a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/StatementSpec.scala b/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/StatementSpec.scala deleted file mode 100644 index fb596403..00000000 --- a/mybatis-scala-core/src/test/scala/org/mybatis/scala/mapping/StatementSpec.scala +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.mapping - -import org.mybatis.scala.config.ConfigurationException -import org.scalatest._ -import scala.util.control.NonFatal -import org.scalatest.funspec.AnyFunSpec -import org.scalatest.matchers.should.Matchers - -/** - * The specification for [[Statement]]. - */ -class StatementSpec extends AnyFunSpec with Matchers { - val simpleStatement = new Statement { - override def parameterTypeClass: Class[_] = classOf[Unit] - override def xsql: XSQL = SELECT 1 - } - - describe("A Statement") { - it("should throw an exception if FQI isn't set") { - intercept[ConfigurationException] { - simpleStatement.execute { - fail("should not come here") - } - } - } - - it("should not throw any exception if FQI is set") { - try { - simpleStatement.fqi = new FQI("databases", "local") - simpleStatement.execute {} - } catch { - case NonFatal(e) => fail(e.getMessage) - } - } - it("should return XSQL") { - simpleStatement.xsql should equal (SELECT 1) - } - } -} diff --git a/mybatis-scala-samples/LICENSE_HEADER b/mybatis-scala-samples/LICENSE_HEADER deleted file mode 100644 index add5c3d1..00000000 --- a/mybatis-scala-samples/LICENSE_HEADER +++ /dev/null @@ -1,13 +0,0 @@ - Copyright 2011-2015 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 - - https://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. diff --git a/mybatis-scala-samples/format.xml b/mybatis-scala-samples/format.xml deleted file mode 100644 index b66080b5..00000000 --- a/mybatis-scala-samples/format.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - diff --git a/mybatis-scala-samples/pom.xml b/mybatis-scala-samples/pom.xml deleted file mode 100644 index b8fc3bf6..00000000 --- a/mybatis-scala-samples/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - - 4.0.0 - - - org.mybatis.scala - mybatis-scala-parent_2.13 - 1.3.2-SNAPSHOT - - - mybatis-scala-samples_2.13 - jar - mybatis-scala-samples - - - scm:git:ssh://github.com/mybatis/scala.git - scm:git:ssh://git@github.com/mybatis/scala.git - HEAD - http://github.com/mybatis/scala - - - - - org.mybatis.scala - mybatis-scala-core_${scala.binary} - ${project.version} - - - org.scala-lang - scala-library - - - org.hsqldb - hsqldb - 2.7.4 - jdk8 - - - - - - - - ${project.basedir}/src/main/resources - - - META-INF - ${project.basedir}/../ - - LICENSE - NOTICE - - - - - - net.alchim31.maven - scala-maven-plugin - - - - maven-deploy-plugin - - true - - - - - - diff --git a/mybatis-scala-samples/src/main/resources/mybatis.xml b/mybatis-scala-samples/src/main/resources/mybatis.xml deleted file mode 100644 index 37812760..00000000 --- a/mybatis-scala-samples/src/main/resources/mybatis.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/mybatis-scala-samples/src/main/resources/sample-data.sql b/mybatis-scala-samples/src/main/resources/sample-data.sql deleted file mode 100644 index c669b526..00000000 --- a/mybatis-scala-samples/src/main/resources/sample-data.sql +++ /dev/null @@ -1,42 +0,0 @@ --- --- Copyright 2011-2015 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 --- --- https://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. --- - -INSERT INTO people_group (id_, name_) - VALUES - (1, 'Customers'), - (2, 'Suppliers'), - (3, 'Employees'); - -INSERT INTO person (id_, first_name_, last_name_, group_id_) - VALUES - (1, 'Brenda', 'Gates', 1), - (2, 'Sara', 'Jobs', 2), - (3, 'Janeth', 'Gosling', 3), - (4, 'John', 'Doe', 1), - (5, 'Mary', 'Jackson', 2); - -INSERT INTO contact_info (owner_id_, street_address_, phone_number_) - VALUES - (1, '637 St Monica', '555-5647809'), - (2, '23 Wall St', '555-0485959'), - (2, '78 Road X', '554-8899888'), - (3, '567 Kong St', '555-0989988'), - (4, '5 Springfield', '555-0909090'), - (5, 'Another place', '555-6978799'); - --- Postgresql only: update sequences -SELECT setval('people_group_id__seq', 4); -SELECT setval('person_id__seq', 6); diff --git a/mybatis-scala-samples/src/main/resources/schema.sql b/mybatis-scala-samples/src/main/resources/schema.sql deleted file mode 100644 index 92cb509f..00000000 --- a/mybatis-scala-samples/src/main/resources/schema.sql +++ /dev/null @@ -1,39 +0,0 @@ --- --- Copyright 2011-2015 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 --- --- https://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. --- - -CREATE TABLE people_group ( - id_ serial, - name_ varchar(255), - primary key (id_) -); - -CREATE TABLE person ( - id_ serial, - first_name_ varchar(255), - last_name_ varchar(255), - group_id_ integer not null, - primary key (id_), - foreign key (group_id_) references people_group(id_) -); - -CREATE TABLE contact_info ( - id_ serial, - owner_id_ integer not null, - street_address_ varchar(255), - phone_number_ varchar(20), - primary key (id_), - foreign key (owner_id_) references person(id_) -); diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Config.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Config.scala deleted file mode 100644 index aed8904a..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Config.scala +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.crud - -import org.mybatis.scala.config._ - -object Config { - - // Load datasource configuration - val config = Configuration("mybatis.xml") - - // Create a configuration space, add the data access method - config.addSpace("item") { space => - space ++= ItemDAO - } - - // Build the session manager - val persistenceContext = config.createPersistenceContext - - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Item.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Item.scala deleted file mode 100644 index 9b6fd7c4..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Item.scala +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.crud - -class Item { - var id : Int = _ - var description : String = _ - var info : Option[String] = None - var year : Option[Int] = None -} - -object Item { - - def apply(description : String, info : Option[String] = None, year : Option[Int] = None) = { - val i = new Item - i.description = description - i.info = info - i.year = year - i - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/ItemDAO.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/ItemDAO.scala deleted file mode 100644 index 8d22948e..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/ItemDAO.scala +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.crud - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.mapping.Binding._ -import org.mybatis.scala.mapping.TypeHandlers._ -import org.mybatis.scala.session.Session -import scala.language.postfixOps - -object ItemDAO { - - val ItemResultMap = new ResultMap[Item] { - id ( column = "id_", property = "id" ) - result ( column = "description_", property = "description" ) - result ( column = "info_", property = "info", jdbcType=JdbcType.VARCHAR ) - result ( column = "year_", property = "year", typeHandler=T[OptIntegerTypeHandler] ) - } - - val SELECT_SQL = - - SELECT * - FROM item - - - val findAll = new SelectList[Item] { - resultMap = ItemResultMap - def xsql = SELECT_SQL - } - - val findByDescription = new SelectListBy[String,Item] { - resultMap = ItemResultMap - def xsql = - - {SELECT_SQL} - WHERE description_ LIKE {"description"?} - ORDER BY description_ - - } - - val findById = new SelectOneBy[Int,Item] { - resultMap = ItemResultMap - def xsql = - - {SELECT_SQL} - WHERE id_ = {"id"?} - - } - - val insert = new Insert[Item] { - def xsql = - - INSERT INTO item(description_, info_, year_) - VALUES ( - { "description"? }, - {? ("info", jdbcType=JdbcType.VARCHAR)}, - {? ("year", jdbcType=JdbcType.INTEGER)} - ) - - } - - val update = new Update[Item] { - def xsql = - - UPDATE item - SET - description_ = {"description"?}, - info_ = {? ("info", jdbcType=JdbcType.VARCHAR)}, - year_ = {? ("year", jdbcType=JdbcType.INTEGER)} - WHERE id_ = {"id"?} - - } - - val DELETE_SQL = - - DELETE FROM item - WHERE id_ = {"id"?} - - - val delete = new Delete[Item] { - def xsql = DELETE_SQL - } - - val deleteById = new Delete[Int] { - def xsql = DELETE_SQL - } - - val dropTable = new Perform { - def xsql = - - DROP TABLE IF EXISTS item - - } - - val createTable = new Perform { - def xsql = - - CREATE TABLE item ( - id_ INTEGER GENERATED BY DEFAULT AS IDENTITY, - description_ varchar(255) not null, - info_ varchar(255), - year_ integer, - primary key (id_) - ) - - } - - def initdb(implicit s : Session) = { - dropTable() - createTable() - } - - def bind = Seq(delete,update,insert,findById,findByDescription,deleteById,findAll,createTable,dropTable) - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Main.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Main.scala deleted file mode 100644 index c5493fb5..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/crud/Main.scala +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.crud - -import org.mybatis.scala.session._ - -object Main extends App { - - val db = Config.persistenceContext - - db.transaction { implicit session => - - // Init the DB: create table etc... - ItemDAO.initdb - - // Insert some items - ItemDAO insert Item("BMW") - ItemDAO insert Item("Ford", Some("USA"), Some(1900)) - ItemDAO insert Item("Renault", Some("France")) - ItemDAO insert Item("Chevrolet") - ItemDAO insert Item("Hyundai", Some("Korea")) - ItemDAO insert Item("Honda", year=Some(1997)) - - // Show ... - println("== Initial values ====================") - ItemDAO.findAll() foreach (printItem _) - - // Change something ... - for (item <- ItemDAO findById(3)) { - item.description = "-CHANGED-" - item.year = Some(2001) - item.info = Some("-MEXICO-") - ItemDAO update item - } - - // Show again ... - println("== With some changes =================") - ItemDAO.findAll() foreach (printItem _) - - // Delete something ... - for (item <- ItemDAO findById(3)) { - ItemDAO delete item - } - - // Show again ... - println("== With some items removed ===========") - ItemDAO.findAll() foreach (printItem _) - - // Show filtered ... - println("== Filtered by H% ====================") - ItemDAO.findByDescription("H%") foreach (printItem _) - - } - - def printItem(i : Item) = - println("%d: %10s\t %10s\t %5s" format (i.id, i.description, i.info.getOrElse("-"), i.year.getOrElse("-"))) - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/delete/DeleteSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/delete/DeleteSample.scala deleted file mode 100644 index 49957fd0..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/delete/DeleteSample.scala +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.delete - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - -object DeleteSample { - - // Simple Person POJO - class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - } - - // Simple select method - val findAll = new SelectList[Person] { - def xsql = - - SELECT id_ as id, first_name_ as firstName, last_name_ as lastName - FROM person - ORDER BY id_ - - } - - val findMaxId = new SelectOne[Int] { - def xsql = - - SELECT MAX(id_) FROM person - - } - - val deletePersonById = new Delete[Int] { - def xsql = - - DELETE FROM person WHERE id_ = #{{id}} - - } - - val deletePersonContacts = new Delete[Int] { - def xsql = - - DELETE FROM contact_info WHERE owner_id_ = #{{id}} - - } - - // Load datasource configuration - val config = Configuration("mybatis.xml") - - // Create a configuration space, add the data access method - config.addSpace("ns1") { space => - space += findAll - space += findMaxId - space += deletePersonById - space += deletePersonContacts - space ++= DBSchema - space ++= DBSampleData - } - - // Build the session manager - val db = config.createPersistenceContext - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - - db.transaction { implicit session => - - DBSchema.create - DBSampleData.populate - - println("Before =>") - for (p <- findAll()) - println( "\tPerson(%d): %s %s".format(p.id, p.firstName, p.lastName) ) - - for(id <- findMaxId()) { - deletePersonContacts(id) - deletePersonById(id) - } - - println("After =>") - for (p <- findAll()) - println( "\tPerson(%d): %s %s".format(p.id, p.firstName, p.lastName) ) - - } - - } - - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSample.scala deleted file mode 100644 index 3db048cd..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSample.scala +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.insert - -import org.mybatis.scala.samples.util._ -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ - -object InsertSample { - - // Simple Group POJO - class Group { - var id : Int = _ - var name : String = _ - } - - // Simple Person POJO - class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - var group : Group = _ - } - - // Simple insert method - val insertPerson = new Insert[Person] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = - - INSERT INTO person (first_name_, last_name_, group_id_) - VALUES (#{{firstName}}, #{{lastName}}, #{{group.id}}) - - } - - // Simple insert method - val insertGroup = new Insert[Group] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = - - INSERT INTO people_group (name_) - VALUES (#{{name}}) - - } - - // Load datasource configuration - val config = Configuration("mybatis.xml") - - // Create a configuration space, add the data access method - config.addSpace("ns1") { space => - space ++= Seq(insertPerson, insertGroup) - space ++= DBSchema - } - - // Build the session manager - val db = config.createPersistenceContext - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - - db.transaction { implicit session => - - DBSchema.create - - val g = new Group - g.name = "New Group" - - val p = new Person - p.firstName = "John" - p.lastName = "Smith" - p.group = g - - insertGroup(g) - insertPerson(p) - - println( "Inserted Person(%d): %s %s".format(p.id, p.firstName, p.lastName) ) - - } - - } - - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSampleBatch.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSampleBatch.scala deleted file mode 100644 index 22ad5142..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/insert/InsertSampleBatch.scala +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.insert - -import org.mybatis.scala.samples.util._ -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ - -object InsertSampleBatch { - - // Simple Group POJO - class Group { - var id : Int = _ - var name : String = _ - } - - // Simple Person POJO - class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - var group : Group = _ - } - - // Simple insert method - val insertPerson = new Insert[Person] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = - - INSERT INTO person (first_name_, last_name_, group_id_) - VALUES (#{{firstName}}, #{{lastName}}, #{{group.id}}) - - } - - // Simple insert method - val insertGroup = new Insert[Group] { - keyGenerator = JdbcGeneratedKey(null, "id") - def xsql = - - INSERT INTO people_group (name_) - VALUES (#{{name}}) - - } - - // Load datasource configuration - val config = Configuration("mybatis.xml") - - // Create a configuration space, add the data access method - config ++= Seq(insertPerson, insertGroup) - config ++= DBSchema - - // Build the session manager - val db = config.createPersistenceContext - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - - db.transaction(ExecutorType.BATCH) { implicit session => - - DBSchema.create - session.flushStatements() - - val g = new Group - g.name = "New Group" - insertGroup(g) - session.flushStatements() - - Seq(("Jonh", "Smith"), ("Mary", "Jane"), ("Pepe", "Grillo")) map { (t) => - val p = new Person - p.firstName = t._1 - p.lastName = t._2 - p.group = g - insertPerson(p) - } - - val created = session.flushStatements() - for (result <- created) { - println( "\n==========================================================" ) - println( result.getSql ) - println( "\nCalled " + result.getUpdateCounts.size + " times") - println( "Total update counts: " + result.getUpdateCounts.foldLeft(0)((a,b)=>a + b) ) - } - - } - - } - - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/nestedselect/NestedSelectSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/nestedselect/NestedSelectSample.scala deleted file mode 100644 index a92af7e1..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/nestedselect/NestedSelectSample.scala +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.nestedselect - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - -// Model beans ================================================================= - -// Simple Group POJO -class Group { - var id : Int = _ - var name : String = _ -} - -// Simple ContactInfo POJO -class ContactInfo { - var id : Int = _ - var address : String = _ - var phone : String = _ -} - -// Simple Person POJO with OneToMany to ContactInfo -class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - var group : Group = _ - var contact : Seq[ContactInfo] = _ -} - -// Data access layer =========================================================== - -object Persistence { - - // Query for a Group - val selectGroup = new SelectOneBy[Int,Group] { - def xsql = - - SELECT id_ as id, name_ as name - FROM people_group - WHERE id_ = #{{id}} - - } - - // Query for a list of contact info - val selectContact = new SelectListBy[Int,ContactInfo] { - resultMap = new ResultMap[ContactInfo] { - id(property="id", column="id_") - result(property="address", column="street_address_") - result(property="phone", column="phone_number_") - } - def xsql = SELECT * FROM contact_info WHERE owner_id_ = #{{id}} - } - - // Query for a list of all persons - val findAll = new SelectList[Person] { - - // Define the result mapping - resultMap = new ResultMap[Person] { - - id(property="id", column="id_") - result(property="firstName", column="first_name_") - result(property="lastName", column="last_name_") - - association[Group] (property="group", column="group_id_", select=selectGroup) - - collection[ContactInfo] (property="contact", column="id_", select=selectContact) - - } - - // Define the actual query - def xsql = - - SELECT * - FROM person p - ORDER BY first_name_ - - } - - // Load datasource configuration from an external file - val config = Configuration("mybatis.xml") - - // Add the data access function to the default namespace - config += findAll - config ++= DBSchema - config ++= DBSampleData - - // Build the session manager - lazy val context = config.createPersistenceContext - -} - -// Application code ============================================================ - -object NestedSelectSample { - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - Persistence.context.transaction { implicit session => - - DBSchema.create - DBSampleData.populate - - for (p <- Persistence.findAll()) { - println("\nPerson(%d): %s %s (%s)".format(p.id, p.firstName, p.lastName, p.group.name)) - for (contact <- p.contact) { - println(" Address: %s, Phone: %s".format(contact.address, contact.phone)) - } - } - - } - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/performance/ProfileTest.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/performance/ProfileTest.scala deleted file mode 100644 index ce97d124..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/performance/ProfileTest.scala +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.performance - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.mapping.Binding._ -import scala.language.postfixOps - -class TestBean { - var id : Int = 0 - var name : String = _ -} - -object ProfileTest extends App { - - // Simple DDL - val createTable = new Perform { - def xsql = - - CREATE TABLE test1 ( - id_ INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) not null, - name_ varchar(255), - primary key (id_) - ) - - } - - // Simple Insert - val insert = new Insert[TestBean] { - def xsql = - - INSERT INTO test1(name_) VALUES ({"name"?}) - - } - - // Simple select - val select = new SelectList[TestBean] { - def xsql = - - SELECT id_ as id, name_ as name - FROM test1 - - } - - // Datasource configuration - val config = Configuration( - Environment( - "default", - new JdbcTransactionFactory(), - new PooledDataSource( - "org.hsqldb.jdbcDriver", - "jdbc:hsqldb:mem:scala", - "sa", - "" - ) - ) - ) - - // Add the data access method to the default namespace - config += createTable - config += insert - config += select - - // Insert 1.000.000 rows - val context = config.createPersistenceContext - context.transaction { implicit s => - createTable() - for (i <- 1 to 1000000) { - val bean = new TestBean() - bean.name = "Bean " + i - insert(bean) - } - } - - // Read 1.000.000 rows into memory - context.readOnly { implicit s => - val resultSeq = select() - } - - // Read 1.000.000 rows one by one - context.readOnly { implicit s => - select.handle[TestBean] { context => - val bean = context.getResultObject - } - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/resultmap/SelectWithResultMapSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/resultmap/SelectWithResultMapSample.scala deleted file mode 100644 index da9c89e4..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/resultmap/SelectWithResultMapSample.scala +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.resultmap - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - - -// Model beans ================================================================= - -// Simple Group POJO -class Group { - var id : Int = _ - var name : String = _ -} - -// Simple ContactInfo POJO -class ContactInfo { - var id : Int = _ - var address : String = _ - var phone : String = _ -} - -// Simple Person POJO with OneToMany to ContactInfo -class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - var group : Group = _ - var contact : Seq[ContactInfo] = _ -} - -// Data access layer =========================================================== - -object Persistence { - - // Simple select function (Nothing) => List[Person] - val findAll = new SelectList[Person] { - - // Define the result mapping - resultMap = new ResultMap[Person] { - - id(property="id", column="id_") - result(property="firstName", column="first_name_") - result(property="lastName", column="last_name_") - - association[Group] (property="group", - resultMap= new ResultMap[Group] { - id(property="id", column="group_id_") - result(property="name", column="group_name_") - } - ) - - collection[ContactInfo] (property="contact", - resultMap= new ResultMap[ContactInfo] { - id(property="id", column="cinfo_id_") - result(property="address", column="street_address_") - result(property="phone", column="phone_number_") - } - ) - - } - - // Define the actual query - def xsql = - - SELECT - p.id_, p.first_name_, p.last_name_, - p.group_id_, g.name_ as group_name_, - c.id_ as cinfo_id_, c.street_address_, c.phone_number_ - FROM - person p - LEFT OUTER JOIN people_group g ON p.group_id_ = g.id_ - LEFT OUTER JOIN contact_info c ON c.owner_id_ = p.id_ - - } - - // Load datasource configuration from an external file - val config = Configuration("mybatis.xml") - - // Add the data access function to the default namespace - config += findAll - config ++= DBSchema - config ++= DBSampleData - - // Build the session manager - lazy val context = config.createPersistenceContext - -} - -// Application code ============================================================ - -object SelectWithResultMapSample { - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - Persistence.context.transaction { implicit session => - - DBSchema.create - DBSampleData.populate - - for (p <- Persistence.findAll()) { - println("\nPerson(%d): %s %s is in group: %s".format(p.id, p.firstName, p.lastName, p.group.name)) - for (contact <- p.contact) { - println(" Address: %s, Phone: %s".format(contact.address, contact.phone)) - } - } - - } - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectImmutableSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectImmutableSample.scala deleted file mode 100644 index 0bcf8523..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectImmutableSample.scala +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.select - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - -// Model beans (Immutable case class) ========================================== - -case class CPerson(id : Int, firstName : String, lastName : String) - -// Data access layer =========================================================== - -object CDB { - - // Simple select function - val findAll = new SelectListBy[String,CPerson] { - - // CPerson Constructor Mapping - resultMap = new ResultMap[CPerson] { - // Warning: Order is important (constructor arguments in order) - idArg ("id_", javaType=T[Int]) - arg ("first_name_", javaType=T[String]) - arg ("last_name_", javaType=T[String]) - } - - def xsql = - """ - SELECT - id_, first_name_, last_name_ - FROM - person - WHERE - first_name_ LIKE #{name} - """ - } - - // Main configuration - object ConfigurationSpec extends Configuration.Builder { - // Connection settings - environment( - id = "default", - transactionFactory = new JdbcTransactionFactory(), - dataSource = new PooledDataSource("org.hsqldb.jdbcDriver", "jdbc:hsqldb:mem:scala", "sa", "") - ) - // Add the data access methods to default namespace - statements(findAll) - mappers(DBSchema, DBSampleData) - } - - // Build the session manager - lazy val context = Configuration(ConfigurationSpec).createPersistenceContext - -} - -// Application code ============================================================ - -object SelectImmutableSample { - - import CDB._ - - // Do the Magic ... - def main(args: Array[String]): Unit = context.transaction { implicit s => - - // Create database and populate it with sample data - DBSchema.create - DBSampleData.populate - - // Query - findAll("%a%").foreach { - case CPerson(id, firstName, lastName) => - println("Person(%d): %s %s" format (id, firstName, lastName)) - } - - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectSample.scala deleted file mode 100644 index a7ef087f..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/select/SelectSample.scala +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.select - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - -// Model beans ================================================================= - -class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ -} - -// Data access layer =========================================================== - -object DB { - - // Simple select function - val findAll = new SelectListBy[String,Person] { - def xsql = - - - SELECT - id_ as id, - first_name_ as firstName, - last_name_ as lastName - FROM - person - WHERE - first_name_ LIKE #{{pattern}} - - } - - // Datasource configuration - val config = Configuration( - Environment( - "default", - new JdbcTransactionFactory(), - new PooledDataSource( - "org.hsqldb.jdbcDriver", - "jdbc:hsqldb:mem:scala", - "sa", - "" - ) - ) - ) - - // Add the data access method to the default namespace - config += findAll - config ++= DBSchema - config ++= DBSampleData - - // Build the session manager - lazy val context = config.createPersistenceContext - -} - -// Application code ============================================================ - -object SelectSample { - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - DB.context.transaction { implicit session => - - DBSchema.create - DBSampleData.populate - - DB.findAll("a").foreach { p => - println( "Person(%d): %s %s".format(p.id, p.firstName, p.lastName) ) - } - - } - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/update/UpdateSample.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/update/UpdateSample.scala deleted file mode 100644 index 37b038a1..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/update/UpdateSample.scala +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.update - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.config._ -import org.mybatis.scala.session._ -import org.mybatis.scala.samples.util._ - -object UpdateSample { - - // Simple Person POJO - class Person { - var id : Int = _ - var firstName : String = _ - var lastName : String = _ - } - - // Simple update method - val updatePerson = new Update[Person] { - def xsql = - - UPDATE person - SET - first_name_ = #{{firstName}}, - last_name_ = #{{lastName}} - WHERE - id_ = #{{id}} - - } - - // Simple select method - val findPerson = new SelectOneBy[Int,Person] { - def xsql = - - SELECT id_ as id, first_name_ as firstName, last_name_ as lastName - FROM person - WHERE id_ = #{{id}} - - } - - - // Load datasource configuration - val config = Configuration("mybatis.xml") - - // Create a configuration space, add the data access method - config.addSpace("ns1") { space => - space += updatePerson += findPerson - } - - config ++= DBSchema - config ++= DBSampleData - - // Build the session manager - val db = config.createPersistenceContext - - // Do the Magic ... - def main(args : Array[String]) : Unit = { - - db.transaction { implicit session => - - DBSchema.create - DBSampleData.populate - - findPerson(1) match { - case Some(p) => - - // Show original - println("Before =>\n\tPerson(%d): %s, %s".format(p.id, p.lastName, p.firstName)) - - // Update a property - p.firstName = "Sun (Updated " + new java.util.Date + ")" - updatePerson(p) - - // Reload to verify - for (p2 <- findPerson(1)) - println( "After =>\n\tPerson(%d): %s, %s".format(p2.id, p2.lastName, p2.firstName) ) - - case None => - println("Person with id=1 does not exists!!!") - } - - } - - } - - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSampleData.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSampleData.scala deleted file mode 100644 index da087710..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSampleData.scala +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.util - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.session._ - -object DBSampleData { - - val insertPerson = new Insert[java.util.Map[_,_]] { - def xsql = - - INSERT INTO person(id_, first_name_, last_name_, group_id_) - VALUES (#{{id}}, #{{firstname}}, #{{lastname}}, #{{group}}) - - } - - val insertGroup = new Insert[java.util.Map[_,_]] { - def xsql = - - INSERT INTO people_group(id_, name_) - VALUES (#{{id}}, #{{name}}) - - } - - val insertContactInfo = new Insert[java.util.Map[_,_]] { - def xsql = - - INSERT INTO contact_info (owner_id_, street_address_, phone_number_) - VALUES (#{{person}}, #{{address}}, #{{phone}}) - - } - - def bind = Seq(insertContactInfo, insertGroup, insertPerson) - - def populate(implicit s : Session) = { - - import scala.jdk.CollectionConverters._ - - insertGroup(Map("id" -> 1, "name" -> "Customers").asJava) - insertGroup(Map("id" -> 2, "name" -> "Suppliers").asJava) - insertGroup(Map("id" -> 3, "name" -> "Employees").asJava) - - insertPerson(Map("id" -> 1, "firstname" -> "John", "lastname" -> "Smart", "group" -> 1).asJava) - insertPerson(Map("id" -> 2, "firstname" -> "Maria", "lastname" -> "Perez", "group" -> 2).asJava) - insertPerson(Map("id" -> 3, "firstname" -> "Janeth", "lastname" -> "Ros", "group" -> 1).asJava) - insertPerson(Map("id" -> 4, "firstname" -> "Paul", "lastname" -> "Jobs", "group" -> 3).asJava) - insertPerson(Map("id" -> 5, "firstname" -> "Bill", "lastname" -> "Rich", "group" -> 1).asJava) - - insertContactInfo(Map("person" -> 1, "address" -> "222 Street", "phone" -> "555-0988998").asJava) - insertContactInfo(Map("person" -> 2, "address" -> "333 Av", "phone" -> "554-7464363").asJava) - insertContactInfo(Map("person" -> 2, "address" -> "1 Rose Ave", "phone" -> "836-8456463").asJava) - insertContactInfo(Map("person" -> 3, "address" -> "444 St Rose", "phone" -> "665-9476558").asJava) - insertContactInfo(Map("person" -> 4, "address" -> "555 Wall Street", "phone" -> "666-7474664").asJava) - insertContactInfo(Map("person" -> 5, "address" -> "666 Mountain View", "phone" -> "571-9875923").asJava) - insertContactInfo(Map("person" -> 5, "address" -> "777 Mars", "phone" -> "587-3984792").asJava) - - } - -} diff --git a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSchema.scala b/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSchema.scala deleted file mode 100644 index 91a1b4e2..00000000 --- a/mybatis-scala-samples/src/main/scala/org/mybatis/scala/samples/util/DBSchema.scala +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2011-2015 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 - * - * https://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.scala.samples.util - -import org.mybatis.scala.mapping._ -import org.mybatis.scala.session.Session - -object DBSchema { - - val createPeopleGroupTable = new Perform { - def xsql = - - CREATE TABLE people_group ( - id_ INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) not null, - name_ varchar(255), - primary key (id_) - ) - - } - - val createPersonTable = new Perform { - def xsql = - - CREATE TABLE person ( - id_ INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) not null, - first_name_ varchar(255), - last_name_ varchar(255), - group_id_ integer not null, - primary key (id_), - foreign key (group_id_) references people_group(id_) - ) - - } - - val createContactInfoTable = new Perform { - def xsql = - - CREATE TABLE contact_info ( - id_ INTEGER GENERATED BY DEFAULT AS IDENTITY (START WITH 1 INCREMENT BY 1) not null, - owner_id_ integer not null, - street_address_ varchar(255), - phone_number_ varchar(20), - primary key (id_), - foreign key (owner_id_) references person(id_) - ) - - } - - val bind = Seq(createPeopleGroupTable, createPersonTable, createContactInfoTable) - - def create(implicit s: Session): Unit = { - createPeopleGroupTable() - createPersonTable() - createContactInfoTable() - } - -} diff --git a/mybatis-scala-samples/src/site/resources/images/ERD.png b/mybatis-scala-samples/src/site/resources/images/ERD.png deleted file mode 100644 index a17d329d..00000000 Binary files a/mybatis-scala-samples/src/site/resources/images/ERD.png and /dev/null differ diff --git a/mybatis-scala-samples/src/site/site.xml b/mybatis-scala-samples/src/site/site.xml deleted file mode 100644 index 7bda769e..00000000 --- a/mybatis-scala-samples/src/site/site.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - diff --git a/mybatis-scala-samples/src/site/xdoc/index.xml b/mybatis-scala-samples/src/site/xdoc/index.xml deleted file mode 100644 index 78339301..00000000 --- a/mybatis-scala-samples/src/site/xdoc/index.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - MyBatis Scala - The MyBatis Team - $Date$ - - - -
-

- There are some examples, each one is based on the same sample database. - See - ERD.png -

-

- - Sample Database ERD -

-

- Also most of them share the same configuration file: - mybatis.xml -

-

- - - - - - - - - - - - - - - -]]> - -

-

- Each example is condensed in one single source file with relevant comments. -

    -
  • - Simple Select without result map: - Code -
  • -
  • - Complex Select with nested resultmaps: - Code -
  • -
  • - Complex Select with nested selects - Code -
  • -
  • - Insert: - Code -
  • -
  • - Update: - Code -
  • -
  • - Delete: - Code -
  • -
-

-

- The CRUD example: A little more complete example. - Code -

-
-
- You can browse all the sample code at: - Source Code -
- - -
diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 8965f86f..00000000 --- a/pom.xml +++ /dev/null @@ -1,190 +0,0 @@ - - - - - 4.0.0 - - - org.mybatis - mybatis-parent - 50 - - - - org.mybatis.scala - mybatis-scala-parent_2.13 - 1.3.2-SNAPSHOT - pom - - mybatis-scala-parent - http://www.mybatis.org/scala/ - - 2011 - - - mybatis-scala-core - mybatis-scala-samples - - - - scm:git:ssh://git@github.com/mybatis/scala.git - scm:git:ssh://git@github.com/mybatis/scala.git - HEAD - http://github.com/mybatis/scala/ - - - GitHub Issue Management - https://github.com/mybatis/scala/issues - - - GitHub Actions - https://github.com/mybatis/scala/actions - - - - gh-pages-scm - Mybatis GitHub Pages - scm:git:ssh://git@github.com/mybatis/scala.git - - - - - 1.2.0 - org.mybatis.scala.* - Scala - 2.13 - 2.13.16 - org.mybatis.scala - - - 1671291815 - - - - - - true - - - - - - org.scala-lang - scala-library - ${scala.version} - - - org.scala-lang.modules - scala-xml_${scala.binary} - 2.4.0 - - - - - - - - - - net.alchim31.maven - scala-maven-plugin - 4.9.5 - - - -deprecation - -feature - - - - - compile - - compile - - compile - - - test-compile - - testCompile - - test-compile - - - - - - - - - org.apache.maven.plugins - maven-release-plugin - - release,bundle - - - - ${project.basedir}/src/main/scala - ${project.basedir}src/test/scala - - - - - eclipse - - - m2e.version - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - net.alchim31.maven - scala-maven-plugin - [4.4.0,) - - testCompile - compile - - - - - - - - - - - - - - - - - diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 5db72dd6..00000000 --- a/renovate.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": [ - "config:recommended" - ] -} diff --git a/src/site/site.xml b/src/site/site.xml deleted file mode 100644 index f23387c7..00000000 --- a/src/site/site.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - diff --git a/src/site/xdoc/index.xml b/src/site/xdoc/index.xml deleted file mode 100644 index 3a26542e..00000000 --- a/src/site/xdoc/index.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - MyBatis Scala - The MyBatis Team - $Date$ - - - -
-

- MyBatis is a persistence framework for Java, so you can use it in Scala as any other - java library, nonetheless the main API is too java centric, it uses Java annotations - and external xml files where you put your SQL. -

-

- The MyBatis Scala API is a lightweight wrapper, it supports a 100% of the framework - functionality, taking advantage of the elegant Scala syntax and its type system. - With this API you can use the Scala collections and "Scala beans", and you can define - all your dynamic SQL code directly in your scala code without String concatenation - and with very clear syntax. -

-

- Appart from the main configuration xml file where you define the datasource and transaction - configurations, you will avoid use of external xml files and java Annotations. -

-

- The main documentation is at the core project: - mybatis-scala-core -

-

- There are some examples here: - mybatis-scala-samples -

-
- - -