├── .gitattributes
├── .github
└── workflows
│ ├── ci.yaml
│ ├── codeql.yml
│ ├── coveralls.yaml
│ ├── samples.yaml
│ ├── site.yaml
│ ├── sonar.yaml
│ └── sonatype.yaml
├── .gitignore
├── .mvn
├── extensions.xml
├── maven.config
├── settings.xml
└── wrapper
│ ├── MavenWrapperDownloader.java
│ └── maven-wrapper.properties
├── CONTRIBUTING.md
├── LICENSE
├── LICENSE_HEADER
├── NOTICE
├── README.md
├── core
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ ├── MyBatisCoreNativeConfiguration.java
│ │ │ ├── MyBatisMapperFactoryBeanPostProcessor.java
│ │ │ ├── MyBatisMapperNativeConfigurationProcessor.java
│ │ │ ├── MyBatisMapperTypeUtils.java
│ │ │ ├── MyBatisResourcesScan.java
│ │ │ ├── MyBatisScannedResourcesHolder.java
│ │ │ ├── MyBatisScannedResourcesNativeConfigurationProcessor.java
│ │ │ ├── MyBatisSpringNativeConfiguration.java
│ │ │ └── autoconfigure
│ │ │ └── MyBatisSpringNativeAutoConfiguration.java
│ └── resources
│ │ └── META-INF
│ │ └── spring.factories
│ ├── site
│ └── site.xml
│ └── test
│ ├── gradle_resources
│ └── mapper
│ │ └── gradle_output
│ │ └── GradleOutputMapper.xml
│ ├── java
│ └── org
│ │ └── mybatis
│ │ └── spring
│ │ └── nativex
│ │ ├── MyBatisMapperFactoryBeanPostProcessorTest.java
│ │ ├── MyBatisMapperNativeConfigurationProcessorTest.java
│ │ ├── MyBatisMapperTypeUtilsTest.java
│ │ ├── MyBatisResourcesScanTest.java
│ │ ├── MyBatisScannedResourcesNativeConfigurationProcessorTest.java
│ │ ├── autoconfigure
│ │ └── MyBatisSpringNativeAutoConfigurationTest.java
│ │ ├── component
│ │ ├── AbstractTypeHandler.java
│ │ ├── BarService.java
│ │ ├── BarTypeHandler.java
│ │ ├── FooTypeHandler.java
│ │ ├── MyAnnotation.java
│ │ ├── MyTypeHandlerInterface.java
│ │ └── TypeHandlers.java
│ │ ├── component2
│ │ └── AnyTypeHandler.java
│ │ ├── entity
│ │ ├── City.java
│ │ ├── Country.java
│ │ ├── EntityMarkerAnnotation.java
│ │ └── EntityMarkerInterface.java
│ │ ├── mapper
│ │ ├── Sample2Mapper.java
│ │ ├── Sample3Mapper.java
│ │ └── SampleMapper.java
│ │ └── marker
│ │ └── StandardEntity.java
│ └── resources
│ └── mapper
│ ├── sub1
│ ├── BarMapper.xml
│ └── FooMapper.xml
│ └── sub2
│ └── AnyMapper.xml
├── docs
├── LICENSE_HEADER
├── pom.xml
└── src
│ └── site
│ ├── ko
│ └── markdown
│ │ └── index.md
│ ├── markdown
│ └── index.md
│ ├── resources
│ ├── css
│ │ └── site.css
│ ├── es
│ │ └── css
│ │ │ └── site.css
│ ├── images
│ │ ├── en.png
│ │ ├── es.png
│ │ ├── ja.png
│ │ ├── ko.png
│ │ └── zh.png
│ ├── ja
│ │ └── css
│ │ │ └── site.css
│ ├── ko
│ │ └── css
│ │ │ └── site.css
│ └── zh
│ │ └── css
│ │ └── site.css
│ ├── site.xml
│ ├── site_ko.xml
│ ├── site_zh.xml
│ └── zh
│ └── markdown
│ └── index.md
├── extensions
├── LICENSE_HEADER
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ ├── MyBatisDynamicSqlNativeConfiguration.java
│ │ │ ├── MyBatisFreeMarkerNativeConfiguration.java
│ │ │ ├── MyBatisThymeleafNativeConfiguration.java
│ │ │ └── MyBatisVelocityNativeConfiguration.java
│ └── resources
│ │ └── META-INF
│ │ └── spring.factories
│ └── site
│ └── site.xml
├── format.xml
├── mvnw
├── mvnw.cmd
├── pom.xml
├── renovate.json
└── samples
├── LICENSE_HEADER
├── cache
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── cache
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── configuration
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── configuration
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── dao
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── dao
│ │ │ ├── City.java
│ │ │ ├── CityDao.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── dao
│ │ └── CityDao.xml
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── dynamic-sql
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── dynamicsql
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── format.xml
├── freemarker
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── freemarker
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ ├── org
│ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── freemarker
│ │ │ └── CityMapper
│ │ │ ├── CityMapper-findAll.ftl
│ │ │ └── CityMapper-insert.ftl
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── pom.xml
├── scan
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ ├── external
│ │ │ ├── entity
│ │ │ │ └── City.java
│ │ │ └── mapper
│ │ │ │ └── CityMapper.java
│ │ │ └── scan
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ ├── mapper
│ │ └── CityMapper.xml
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── simple
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── simple
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── sqlprovider
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── sqlprovider
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── thymeleaf-sqlgenerator
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── thymeleaf
│ │ │ ├── City.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ ├── schema.sql
│ │ └── sqls
│ │ └── city
│ │ ├── city-findAll.sql
│ │ └── city-insert.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── thymeleaf
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── thymeleaf
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ ├── org
│ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── thymeleaf
│ │ │ └── CityMapper
│ │ │ ├── CityMapper-findAll.sql
│ │ │ └── CityMapper-insert.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
├── velocity
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
│ ├── main
│ ├── java
│ │ └── org
│ │ │ └── mybatis
│ │ │ └── spring
│ │ │ └── nativex
│ │ │ └── sample
│ │ │ └── velocity
│ │ │ ├── City.java
│ │ │ ├── CityMapper.java
│ │ │ └── MybatisSpringNativeSampleApplication.java
│ └── resources
│ │ ├── application.properties
│ │ ├── data.sql
│ │ └── schema.sql
│ └── test
│ └── resources
│ └── expected-console.log
└── xml
├── LICENSE_HEADER
├── format.xml
├── pom.xml
└── src
├── main
├── java
│ └── org
│ │ └── mybatis
│ │ └── spring
│ │ └── nativex
│ │ └── sample
│ │ └── xml
│ │ ├── City.java
│ │ ├── CityMapper.java
│ │ └── MybatisSpringNativeSampleApplication.java
└── resources
│ ├── application.properties
│ ├── data.sql
│ ├── org
│ └── mybatis
│ │ └── spring
│ │ └── nativex
│ │ └── sample
│ │ └── xml
│ │ └── CityMapper.xml
│ └── schema.sql
└── test
└── resources
└── expected-console.log
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
--------------------------------------------------------------------------------
/.github/workflows/ci.yaml:
--------------------------------------------------------------------------------
1 | name: Java CI
2 |
3 | on: [workflow_dispatch, push, pull_request]
4 |
5 | permissions: read-all
6 |
7 | jobs:
8 | test:
9 | runs-on: ${{ matrix.os }}
10 | strategy:
11 | matrix:
12 | cache: [maven]
13 | distribution: [temurin]
14 | java: [17, 21, 24, 25-ea]
15 | os: [ubuntu-latest, macos-latest, windows-latest]
16 | fail-fast: false
17 | max-parallel: 4
18 | name: Test JDK ${{ matrix.java }}, ${{ matrix.os }}
19 |
20 | steps:
21 | - uses: actions/checkout@v4
22 | - name: Set up JDK ${{ matrix.java }} ${{ matrix.distribution }}
23 | uses: actions/setup-java@v4
24 | with:
25 | java-version: ${{ matrix.java }}
26 | distribution: ${{ matrix.distribution }}
27 | cache: ${{ matrix.cache }}
28 | - name: Test with Maven
29 | run: ./mvnw -pl core,extensions test -B -V --no-transfer-progress -D"license.skip=true"
30 |
--------------------------------------------------------------------------------
/.github/workflows/codeql.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 | pull_request:
7 | branches: [ "master" ]
8 | schedule:
9 | - cron: '22 16 * * 4'
10 |
11 | jobs:
12 | analyze:
13 | name: Analyze
14 | runs-on: ${{ (matrix.language == 'swift' && 'macos-latest') || 'ubuntu-latest' }}
15 | timeout-minutes: ${{ (matrix.language == 'swift' && 120) || 360 }}
16 | permissions:
17 | actions: read
18 | contents: read
19 | security-events: write
20 |
21 | strategy:
22 | fail-fast: false
23 | matrix:
24 | language: [ 'java-kotlin' ]
25 |
26 | steps:
27 | - name: Checkout repository
28 | uses: actions/checkout@v4
29 |
30 | - name: Setup Java
31 | uses: actions/setup-java@v4
32 | with:
33 | cache: maven
34 | distribution: 'temurin'
35 | java-version: 21
36 |
37 | - name: Initialize CodeQL
38 | uses: github/codeql-action/init@v3
39 | with:
40 | languages: ${{ matrix.language }}
41 | queries: +security-and-quality
42 |
43 | - name: Autobuild
44 | uses: github/codeql-action/autobuild@v3
45 |
46 | - name: Perform CodeQL Analysis
47 | uses: github/codeql-action/analyze@v3
48 | with:
49 | category: "/language:${{ matrix.language }}"
50 |
--------------------------------------------------------------------------------
/.github/workflows/coveralls.yaml:
--------------------------------------------------------------------------------
1 | name: Coveralls
2 |
3 | on: [push, pull_request]
4 |
5 | permissions: read-all
6 |
7 | jobs:
8 | build:
9 | if: github.repository_owner == 'mybatis'
10 | runs-on: ubuntu-latest
11 | steps:
12 | - uses: actions/checkout@v4
13 | - name: Set up JDK
14 | uses: actions/setup-java@v4
15 | with:
16 | cache: maven
17 | distribution: temurin
18 | java-version: 21
19 | - name: Report Coverage to Coveralls for Pull Requests
20 | if: github.event_name == 'pull_request'
21 | run: ./mvnw -pl core,extensions -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github -DpullRequest=$PR_NUMBER --no-transfer-progress
22 | env:
23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 | PR_NUMBER: ${{ github.event.number }}
25 | - name: Report Coverage to Coveralls for General Push
26 | if: github.event_name == 'push'
27 | run: ./mvnw -B -V test jacoco:report coveralls:report -q -Dlicense.skip=true -DrepoToken=$GITHUB_TOKEN -DserviceName=github --no-transfer-progress
28 | env:
29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30 |
--------------------------------------------------------------------------------
/.github/workflows/site.yaml:
--------------------------------------------------------------------------------
1 | name: Site
2 |
3 | on:
4 | push:
5 | branches:
6 | - site
7 |
8 | permissions:
9 | contents: write
10 |
11 | jobs:
12 | build:
13 | if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]')
14 | runs-on: ubuntu-latest
15 | steps:
16 | - uses: actions/checkout@v4
17 | - name: Set up JDK
18 | uses: actions/setup-java@v4
19 | with:
20 | cache: maven
21 | distribution: temurin
22 | java-version: 21
23 | - name: Build site
24 | run: ./mvnw site site:stage -DskipTests -Dlicense.skip=true -B -V --no-transfer-progress --settings ./.mvn/settings.xml
25 | env:
26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
27 | NVD_API_KEY: ${{ secrets.NVD_API_KEY }}
28 | - name: Deploy Site to gh-pages
29 | uses: JamesIves/github-pages-deploy-action@v4
30 | with:
31 | branch: gh-pages
32 | folder: target/staging
33 |
--------------------------------------------------------------------------------
/.github/workflows/sonar.yaml:
--------------------------------------------------------------------------------
1 | name: SonarCloud
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | permissions: read-all
9 |
10 | jobs:
11 | build:
12 | if: github.repository_owner == 'mybatis'
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | with:
17 | # Disabling shallow clone is recommended for improving relevancy of reporting
18 | fetch-depth: 0
19 | - name: Set up JDK
20 | uses: actions/setup-java@v4
21 | with:
22 | cache: maven
23 | distribution: temurin
24 | java-version: 21
25 | - name: Analyze with SonarCloud
26 | run: ./mvnw verify jacoco:report sonar:sonar -B -V -Dsonar.projectKey=mybatis_spring-native -Dsonar.organization=mybatis -Dsonar.host.url=https://sonarcloud.io -Dsonar.token=$SONAR_TOKEN -Dlicense.skip=true --no-transfer-progress
27 | env:
28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29 | SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
30 |
--------------------------------------------------------------------------------
/.github/workflows/sonatype.yaml:
--------------------------------------------------------------------------------
1 | name: Sonatype
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 |
8 | permissions: read-all
9 |
10 | jobs:
11 | build:
12 | if: github.repository_owner == 'mybatis' && ! contains(toJSON(github.event.head_commit.message), '[maven-release-plugin]')
13 | runs-on: ubuntu-latest
14 | steps:
15 | - uses: actions/checkout@v4
16 | - name: Set up JDK
17 | uses: actions/setup-java@v4
18 | with:
19 | cache: maven
20 | distribution: temurin
21 | java-version: 21
22 | - name: Deploy to Sonatype
23 | run: ./mvnw deploy -DskipTests -B -V --no-transfer-progress --settings ./.mvn/settings.xml -Dlicense.skip=true
24 | env:
25 | CI_DEPLOY_USERNAME: ${{ secrets.CI_DEPLOY_USERNAME }}
26 | CI_DEPLOY_PASSWORD: ${{ secrets.CI_DEPLOY_PASSWORD }}
27 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | HELP.md
2 | target/
3 | .mvn/wrapper/maven-wrapper.jar
4 | !**/src/main/**/target/
5 | !**/src/test/**/target/
6 | .github/keys/
7 |
8 | ### STS ###
9 | .apt_generated
10 | .classpath
11 | .factorypath
12 | .project
13 | .settings
14 | .springBeans
15 | .sts4-cache
16 |
17 | ### IntelliJ IDEA ###
18 | .idea
19 | *.iws
20 | *.iml
21 | *.ipr
22 |
23 | ### NetBeans ###
24 | /nbproject/private/
25 | /nbbuild/
26 | /dist/
27 | /nbdist/
28 | /.nb-gradle/
29 | build/
30 | !**/src/main/**/build/
31 | !**/src/test/**/build/
32 |
33 | ### VS Code ###
34 | .vscode/
35 |
--------------------------------------------------------------------------------
/.mvn/extensions.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 | fr.jcgay.maven
22 | maven-profiler
23 | 3.3
24 |
25 |
26 |
--------------------------------------------------------------------------------
/.mvn/maven.config:
--------------------------------------------------------------------------------
1 | -Daether.checksums.algorithms=SHA-512,SHA-256,SHA-1,MD5
2 | -Daether.connector.smartChecksums=false
3 |
--------------------------------------------------------------------------------
/.mvn/settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
23 |
24 |
25 | central
26 | ${env.CI_DEPLOY_USERNAME}
27 | ${env.CI_DEPLOY_PASSWORD}
28 |
29 |
30 |
31 |
32 | gh-pages-scm
33 |
34 | branch
35 | gh-pages
36 |
37 |
38 |
39 |
40 |
41 | github
42 | ${env.GITHUB_TOKEN}
43 |
44 |
45 |
46 |
47 | nvd
48 | ${env.NVD_API_KEY}
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # https://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | wrapperVersion=3.3.2
18 | distributionType=source
19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.9/apache-maven-3.9.9-bin.zip
20 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.3.2/maven-wrapper-3.3.2.jar
21 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | Please see [the MyBatis core module Guideline](https://github.com/mybatis/mybatis-3/blob/master/CONTRIBUTING.md).
2 |
--------------------------------------------------------------------------------
/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/NOTICE:
--------------------------------------------------------------------------------
1 | MyBatis Spring Native
2 | Copyright 2022-2023
3 |
4 | This product includes software developed by
5 | The MyBatis Team (https://www.mybatis.org/).
6 |
--------------------------------------------------------------------------------
/core/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/core/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/core/src/main/java/org/mybatis/spring/nativex/MyBatisMapperTypeUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex;
17 |
18 | import java.lang.reflect.Method;
19 | import java.lang.reflect.ParameterizedType;
20 | import java.lang.reflect.Type;
21 | import java.util.Map;
22 | import java.util.Set;
23 | import java.util.stream.Collectors;
24 | import java.util.stream.Stream;
25 |
26 | import org.apache.ibatis.reflection.TypeParameterResolver;
27 |
28 | final class MyBatisMapperTypeUtils {
29 |
30 | private MyBatisMapperTypeUtils() {
31 | // NOP
32 | }
33 |
34 | static Class> resolveReturnClass(Class> mapperInterface, Method method) {
35 | Type resolvedReturnType = TypeParameterResolver.resolveReturnType(method, mapperInterface);
36 | return typeToClass(resolvedReturnType, method.getReturnType());
37 | }
38 |
39 | static Set> resolveParameterClasses(Class> mapperInterface, Method method) {
40 | return Stream.of(TypeParameterResolver.resolveParamTypes(method, mapperInterface))
41 | .map(x -> typeToClass(x, x instanceof Class ? (Class>) x : Object.class)).collect(Collectors.toSet());
42 | }
43 |
44 | private static Class> typeToClass(Type src, Class> fallback) {
45 | Class> result = null;
46 | if (src instanceof Class>) {
47 | if (((Class>) src).isArray()) {
48 | result = ((Class>) src).getComponentType();
49 | } else {
50 | result = (Class>) src;
51 | }
52 | } else if (src instanceof ParameterizedType) {
53 | ParameterizedType parameterizedType = (ParameterizedType) src;
54 | int index = (parameterizedType.getRawType() instanceof Class
55 | && Map.class.isAssignableFrom((Class>) parameterizedType.getRawType())
56 | && parameterizedType.getActualTypeArguments().length > 1) ? 1 : 0;
57 | Type actualType = parameterizedType.getActualTypeArguments()[index];
58 | result = typeToClass(actualType, fallback);
59 | }
60 | if (result == null) {
61 | result = fallback;
62 | }
63 | return result;
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/core/src/main/java/org/mybatis/spring/nativex/MyBatisSpringNativeConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex;
17 |
18 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_CLASSES;
19 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_CONSTRUCTORS;
20 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_FIELDS;
21 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_METHODS;
22 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_CLASSES;
23 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_CONSTRUCTORS;
24 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_FIELDS;
25 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_METHODS;
26 |
27 | import org.mybatis.spring.SqlSessionFactoryBean;
28 | import org.mybatis.spring.SqlSessionTemplate;
29 | import org.springframework.nativex.hint.NativeHint;
30 | import org.springframework.nativex.hint.ResourceHint;
31 | import org.springframework.nativex.hint.TypeHint;
32 | import org.springframework.nativex.type.NativeConfiguration;
33 |
34 | /**
35 | * Registers hints to make a MyBatis Spring component work in a Spring Native context.
36 | *
37 | * @author Kazuki Shimizu
38 | */
39 | // @formatter:off
40 | @NativeHint(
41 | trigger = SqlSessionTemplate.class,
42 | resources = @ResourceHint(
43 | patterns = "org/mybatis/spring/config/.*.xsd"
44 | )
45 | )
46 | @TypeHint(
47 | types = SqlSessionFactoryBean.class,
48 | access = {
49 | PUBLIC_CONSTRUCTORS,
50 | PUBLIC_CLASSES,
51 | PUBLIC_FIELDS,
52 | PUBLIC_METHODS,
53 | DECLARED_CLASSES,
54 | DECLARED_CONSTRUCTORS,
55 | DECLARED_FIELDS,
56 | DECLARED_METHODS
57 | }
58 | )
59 | // @formatter:on
60 | public class MyBatisSpringNativeConfiguration implements NativeConfiguration {
61 | }
62 |
--------------------------------------------------------------------------------
/core/src/main/java/org/mybatis/spring/nativex/autoconfigure/MyBatisSpringNativeAutoConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.autoconfigure;
17 |
18 | import java.util.List;
19 |
20 | import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
21 | import org.mybatis.spring.boot.autoconfigure.MybatisAutoConfiguration;
22 | import org.mybatis.spring.boot.autoconfigure.SqlSessionFactoryBeanCustomizer;
23 | import org.mybatis.spring.nativex.MyBatisScannedResourcesHolder;
24 | import org.springframework.boot.autoconfigure.AutoConfigureBefore;
25 | import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
26 | import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
27 | import org.springframework.context.annotation.Bean;
28 | import org.springframework.context.annotation.Configuration;
29 | import org.springframework.core.io.ClassPathResource;
30 | import org.springframework.core.io.Resource;
31 |
32 | /**
33 | * The configuration class that configure automatically for spring-native.
34 | *
35 | * @author Kazuki Shimizu
36 | */
37 | @Configuration
38 | @ConditionalOnClass({ org.apache.ibatis.session.Configuration.class, SqlSessionFactoryBeanCustomizer.class })
39 | @AutoConfigureBefore(MybatisAutoConfiguration.class)
40 | public class MyBatisSpringNativeAutoConfiguration {
41 |
42 | @ConditionalOnBean(MyBatisScannedResourcesHolder.class)
43 | @Bean
44 | ConfigurationCustomizer mybatisScannedResourcesHolderConfigurationCustomizer(
45 | List holders) {
46 | return configuration -> holders.forEach(holder -> {
47 | holder.getTypeAliasesClasses().forEach(configuration.getTypeAliasRegistry()::registerAlias);
48 | holder.getTypeHandlerClasses().forEach(configuration.getTypeHandlerRegistry()::register);
49 | });
50 | }
51 |
52 | @ConditionalOnBean(MyBatisScannedResourcesHolder.class)
53 | @Bean
54 | SqlSessionFactoryBeanCustomizer mybatisScannedResourcesHolderSqlSessionFactoryBeanCustomizer(
55 | List holders) {
56 | return factoryBean -> {
57 | Resource[] resources = holders.stream()
58 | .flatMap(holder -> holder.getMapperLocations().stream().map(ClassPathResource::new)).toArray(Resource[]::new);
59 | if (resources.length > 0) {
60 | factoryBean.setMapperLocations(resources);
61 | }
62 | };
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/core/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | org.springframework.aot.context.bootstrap.generator.infrastructure.nativex.BeanFactoryNativeConfigurationProcessor=\
18 | org.mybatis.spring.nativex.MyBatisMapperNativeConfigurationProcessor,\
19 | org.mybatis.spring.nativex.MyBatisScannedResourcesNativeConfigurationProcessor
20 | org.springframework.context.annotation.BeanDefinitionPostProcessor=\
21 | org.mybatis.spring.nativex.MyBatisMapperFactoryBeanPostProcessor
22 | org.springframework.nativex.type.NativeConfiguration=\
23 | org.mybatis.spring.nativex.MyBatisCoreNativeConfiguration,\
24 | org.mybatis.spring.nativex.MyBatisSpringNativeConfiguration
25 | org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
26 | org.mybatis.spring.nativex.autoconfigure.MyBatisSpringNativeAutoConfiguration
27 |
--------------------------------------------------------------------------------
/core/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/core/src/test/gradle_resources/mapper/gradle_output/GradleOutputMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/AbstractTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | import org.apache.ibatis.type.BaseTypeHandler;
19 |
20 | public abstract class AbstractTypeHandler extends BaseTypeHandler {
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/BarService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | public class BarService {
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/BarTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 |
22 | import org.apache.ibatis.type.BaseTypeHandler;
23 | import org.apache.ibatis.type.JdbcType;
24 |
25 | public class BarTypeHandler extends BaseTypeHandler {
26 |
27 | @Override
28 | public void setNonNullParameter(PreparedStatement ps, int i, Integer parameter, JdbcType jdbcType) {
29 | }
30 |
31 | @Override
32 | public Integer getNullableResult(ResultSet rs, String columnName) {
33 | return null;
34 | }
35 |
36 | @Override
37 | public Integer getNullableResult(ResultSet rs, int columnIndex) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public Integer getNullableResult(CallableStatement cs, int columnIndex) {
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/FooTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 |
22 | import org.apache.ibatis.type.BaseTypeHandler;
23 | import org.apache.ibatis.type.JdbcType;
24 |
25 | public class FooTypeHandler extends BaseTypeHandler {
26 |
27 | @Override
28 | public void setNonNullParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) {
29 | }
30 |
31 | @Override
32 | public String getNullableResult(ResultSet rs, String columnName) {
33 | return null;
34 | }
35 |
36 | @Override
37 | public String getNullableResult(ResultSet rs, int columnIndex) {
38 | return null;
39 | }
40 |
41 | @Override
42 | public String getNullableResult(CallableStatement cs, int columnIndex) {
43 | return null;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/MyAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | @SuppressWarnings("unused")
19 | public @interface MyAnnotation {
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/MyTypeHandlerInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | import org.apache.ibatis.type.TypeHandler;
19 |
20 | @SuppressWarnings("unused")
21 | public interface MyTypeHandlerInterface extends TypeHandler {
22 | }
23 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component/TypeHandlers.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component;
17 |
18 | import java.sql.CallableStatement;
19 | import java.sql.PreparedStatement;
20 | import java.sql.ResultSet;
21 |
22 | import org.apache.ibatis.type.JdbcType;
23 | import org.apache.ibatis.type.TypeHandler;
24 |
25 | public class TypeHandlers {
26 |
27 | @SuppressWarnings("unused")
28 | BarTypeHandler anonymous = new BarTypeHandler() {
29 | @Override
30 | public String toString() {
31 | return super.toString();
32 | }
33 | };
34 |
35 | public static class InnerTypeHandler implements TypeHandler {
36 |
37 | @Override
38 | public void setParameter(PreparedStatement ps, int i, String parameter, JdbcType jdbcType) {
39 |
40 | }
41 |
42 | @Override
43 | public String getResult(ResultSet rs, String columnName) {
44 | return null;
45 | }
46 |
47 | @Override
48 | public String getResult(ResultSet rs, int columnIndex) {
49 | return null;
50 | }
51 |
52 | @Override
53 | public String getResult(CallableStatement cs, int columnIndex) {
54 | return null;
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/component2/AnyTypeHandler.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.component2;
17 |
18 | import java.math.BigDecimal;
19 | import java.sql.CallableStatement;
20 | import java.sql.PreparedStatement;
21 | import java.sql.ResultSet;
22 |
23 | import org.apache.ibatis.type.BaseTypeHandler;
24 | import org.apache.ibatis.type.JdbcType;
25 |
26 | public class AnyTypeHandler extends BaseTypeHandler {
27 |
28 | @Override
29 | public void setNonNullParameter(PreparedStatement ps, int i, BigDecimal parameter, JdbcType jdbcType) {
30 | }
31 |
32 | @Override
33 | public BigDecimal getNullableResult(ResultSet rs, String columnName) {
34 | return null;
35 | }
36 |
37 | @Override
38 | public BigDecimal getNullableResult(ResultSet rs, int columnIndex) {
39 | return null;
40 | }
41 |
42 | @Override
43 | public BigDecimal getNullableResult(CallableStatement cs, int columnIndex) {
44 | return null;
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/entity/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.entity;
17 |
18 | public class City {
19 | @SuppressWarnings("unused")
20 | City anonymous = new City() {
21 | @Override
22 | public String toString() {
23 | return super.toString();
24 | }
25 | };
26 | }
27 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/entity/Country.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.entity;
17 |
18 | import org.mybatis.spring.nativex.marker.StandardEntity;
19 |
20 | public class Country extends StandardEntity {
21 | }
22 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/entity/EntityMarkerAnnotation.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.entity;
17 |
18 | @SuppressWarnings("unused")
19 | public @interface EntityMarkerAnnotation {
20 | }
21 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/entity/EntityMarkerInterface.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.entity;
17 |
18 | @SuppressWarnings("unused")
19 | public interface EntityMarkerInterface {
20 |
21 | class MemberEntity {
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/mapper/Sample2Mapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.mapper;
17 |
18 | public class Sample2Mapper {
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/mapper/Sample3Mapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.mapper;
17 |
18 | public class Sample3Mapper {
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/mapper/SampleMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.mapper;
17 |
18 | import java.math.BigDecimal;
19 | import java.util.Collection;
20 | import java.util.Collections;
21 | import java.util.Date;
22 |
23 | import org.apache.ibatis.annotations.InsertProvider;
24 | import org.apache.ibatis.annotations.SelectProvider;
25 |
26 | public interface SampleMapper {
27 |
28 | Sample find(SampleParam param);
29 |
30 | default Collection find(Collection params) {
31 | return Collections.emptyList();
32 | }
33 |
34 | @SelectProvider(SelectProviderClass1.class)
35 | String select1();
36 |
37 | @SelectProvider(type = SelectProviderClass2.class)
38 | BigDecimal select2();
39 |
40 | @InsertProvider(InsertProviderClass1.class)
41 | void insert1();
42 |
43 | @InsertProvider(type = InsertProviderClass2.class)
44 | boolean insert2();
45 |
46 | @InsertProvider(UpdateProviderClass1.class)
47 | Long update1();
48 |
49 | @InsertProvider(type = UpdateProviderClass2.class)
50 | Date update2();
51 |
52 | @InsertProvider(DeleteProviderClass1.class)
53 | Short delete1();
54 |
55 | @InsertProvider(type = DeleteProviderClass2.class)
56 | Object delete2();
57 |
58 | int count();
59 |
60 | class SampleParam {
61 |
62 | }
63 |
64 | class Sample {
65 |
66 | }
67 |
68 | class Sample2Param {
69 |
70 | }
71 |
72 | class Sample2 {
73 |
74 | }
75 |
76 | class SelectProviderClass1 {
77 |
78 | }
79 |
80 | class SelectProviderClass2 {
81 |
82 | }
83 |
84 | class InsertProviderClass1 {
85 |
86 | }
87 |
88 | class InsertProviderClass2 {
89 |
90 | }
91 |
92 | class UpdateProviderClass1 {
93 |
94 | }
95 |
96 | class UpdateProviderClass2 {
97 |
98 | }
99 |
100 | class DeleteProviderClass1 {
101 |
102 | }
103 |
104 | class DeleteProviderClass2 {
105 |
106 | }
107 | }
108 |
--------------------------------------------------------------------------------
/core/src/test/java/org/mybatis/spring/nativex/marker/StandardEntity.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.marker;
17 |
18 | public class StandardEntity {
19 | }
20 |
--------------------------------------------------------------------------------
/core/src/test/resources/mapper/sub1/BarMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/core/src/test/resources/mapper/sub1/FooMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/core/src/test/resources/mapper/sub2/AnyMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/docs/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/docs/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | 4.0.0
21 |
22 |
23 | org.mybatis.spring.native
24 | mybatis-spring-native
25 | 0.1.0-SNAPSHOT
26 |
27 |
28 | mybatis-spring-native-docs
29 | mybatis-spring-native-docs
30 | Documents for MyBatis integration with Spring Native feature
31 |
32 |
33 | org.mybatis.spring.nativex.docs
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/docs/src/site/resources/css/site.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * when new flags are needed, take them from
18 | *
19 | * https://www.printableworldflags.com/flag-icon
20 | *
21 | * that are free for any kind of usage
22 | */
23 |
24 | ul.i18n {list-style-type:none;}
25 | li.en {background: url('../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
26 | li.es {background: url('../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
27 | li.ja {background: url('../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
28 | li.zh {background: url('../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
29 | li.ko {background: url('../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}
--------------------------------------------------------------------------------
/docs/src/site/resources/es/css/site.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * when new flags are needed, take them from
18 | *
19 | * https://www.printableworldflags.com/flag-icon
20 | *
21 | * that are free for any kind of usage
22 | */
23 |
24 | ul.i18n {list-style-type:none;}
25 | li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
26 | li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
27 | li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
28 | li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
29 | li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}
--------------------------------------------------------------------------------
/docs/src/site/resources/images/en.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybatis/spring-native/32555e6536256c29412236b9cbda9477969f3a32/docs/src/site/resources/images/en.png
--------------------------------------------------------------------------------
/docs/src/site/resources/images/es.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybatis/spring-native/32555e6536256c29412236b9cbda9477969f3a32/docs/src/site/resources/images/es.png
--------------------------------------------------------------------------------
/docs/src/site/resources/images/ja.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybatis/spring-native/32555e6536256c29412236b9cbda9477969f3a32/docs/src/site/resources/images/ja.png
--------------------------------------------------------------------------------
/docs/src/site/resources/images/ko.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybatis/spring-native/32555e6536256c29412236b9cbda9477969f3a32/docs/src/site/resources/images/ko.png
--------------------------------------------------------------------------------
/docs/src/site/resources/images/zh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/mybatis/spring-native/32555e6536256c29412236b9cbda9477969f3a32/docs/src/site/resources/images/zh.png
--------------------------------------------------------------------------------
/docs/src/site/resources/ja/css/site.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * when new flags are needed, take them from
18 | *
19 | * https://www.printableworldflags.com/flag-icon
20 | *
21 | * that are free for any kind of usage
22 | */
23 |
24 | ul.i18n {list-style-type:none;}
25 | li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
26 | li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
27 | li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
28 | li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
29 | li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}
--------------------------------------------------------------------------------
/docs/src/site/resources/ko/css/site.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * when new flags are needed, take them from
18 | *
19 | * https://www.printableworldflags.com/flag-icon
20 | *
21 | * that are free for any kind of usage
22 | */
23 |
24 | ul.i18n {list-style-type:none;}
25 | li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
26 | li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
27 | li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
28 | li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
29 | li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}
--------------------------------------------------------------------------------
/docs/src/site/resources/zh/css/site.css:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | /*
17 | * when new flags are needed, take them from
18 | *
19 | * https://www.printableworldflags.com/flag-icon
20 | *
21 | * that are free for any kind of usage
22 | */
23 |
24 | ul.i18n {list-style-type:none;}
25 | li.en {background: url('../../images/en.png') left no-repeat;padding-left: 32px; margin: 10px}
26 | li.es {background: url('../../images/es.png') left no-repeat;padding-left: 32px; margin: 10px}
27 | li.ja {background: url('../../images/ja.png') left no-repeat;padding-left: 32px; margin: 10px}
28 | li.zh {background: url('../../images/zh.png') left no-repeat;padding-left: 32px; margin: 10px}
29 | li.ko {background: url('../../images/ko.png') left no-repeat;padding-left: 32px; margin: 10px}
--------------------------------------------------------------------------------
/docs/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/src/site/site_ko.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
24 |
25 |
--------------------------------------------------------------------------------
/docs/src/site/site_zh.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
24 |
25 |
--------------------------------------------------------------------------------
/extensions/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/extensions/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | 4.0.0
21 |
22 |
23 | org.mybatis.spring.native
24 | mybatis-spring-native
25 | 0.1.0-SNAPSHOT
26 |
27 |
28 | mybatis-spring-native-extensions
29 | mybatis-spring-native-extensions
30 | MyBatis integration with Spring Native feature for extension modules(scripting, cache, and more)
31 |
32 |
33 | org.mybatis.spring.nativex.extensions
34 |
35 |
36 |
37 |
38 | org.mybatis.spring.native
39 | mybatis-spring-native-core
40 | ${project.version}
41 |
42 |
43 | org.mybatis.scripting
44 | mybatis-thymeleaf
45 | provided
46 | true
47 |
48 |
49 | org.mybatis.scripting
50 | mybatis-velocity
51 | provided
52 | true
53 |
54 |
55 | org.mybatis.scripting
56 | mybatis-freemarker
57 | provided
58 | true
59 |
60 |
61 | org.mybatis.dynamic-sql
62 | mybatis-dynamic-sql
63 | provided
64 | true
65 |
66 |
67 | org.springframework.experimental
68 | spring-native
69 | provided
70 |
71 |
72 | org.springframework.experimental
73 | spring-aot
74 | provided
75 |
76 |
77 |
78 |
79 |
--------------------------------------------------------------------------------
/extensions/src/main/java/org/mybatis/spring/nativex/MyBatisFreeMarkerNativeConfiguration.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex;
17 |
18 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_CLASSES;
19 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_CONSTRUCTORS;
20 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_FIELDS;
21 | import static org.springframework.nativex.hint.TypeAccess.DECLARED_METHODS;
22 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_CLASSES;
23 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_CONSTRUCTORS;
24 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_FIELDS;
25 | import static org.springframework.nativex.hint.TypeAccess.PUBLIC_METHODS;
26 |
27 | import org.mybatis.scripting.freemarker.FreeMarkerLanguageDriver;
28 | import org.mybatis.scripting.freemarker.FreeMarkerLanguageDriverConfig;
29 | import org.mybatis.scripting.freemarker.support.TemplateFilePathProvider;
30 | import org.springframework.nativex.hint.NativeHint;
31 | import org.springframework.nativex.hint.ResourceHint;
32 | import org.springframework.nativex.hint.TypeHint;
33 | import org.springframework.nativex.type.NativeConfiguration;
34 |
35 | /**
36 | * Registers hints to make a MyBatis FreeMarker component work in a Spring Native context.
37 | *
38 | * @author Kazuki Shimizu
39 | */
40 | // @formatter:off
41 | @NativeHint(
42 | trigger = FreeMarkerLanguageDriver.class,
43 | resources = @ResourceHint(
44 | patterns = {
45 | "mybatis-freemarker.properties",
46 | "freemarker/version.properties",
47 | "freemarker/ext/beans/DefaultMemberAccessPolicy-rules"
48 | }
49 | )
50 | )
51 | @TypeHint(
52 | types = {
53 | FreeMarkerLanguageDriver.class,
54 | FreeMarkerLanguageDriverConfig.class,
55 | TemplateFilePathProvider.class
56 | },
57 | access = {
58 | PUBLIC_CONSTRUCTORS,
59 | PUBLIC_CLASSES,
60 | PUBLIC_FIELDS,
61 | PUBLIC_METHODS,
62 | DECLARED_CLASSES,
63 | DECLARED_CONSTRUCTORS,
64 | DECLARED_FIELDS,
65 | DECLARED_METHODS
66 | }
67 | )
68 | // @formatter:on
69 | public class MyBatisFreeMarkerNativeConfiguration implements NativeConfiguration {
70 | }
71 |
--------------------------------------------------------------------------------
/extensions/src/main/resources/META-INF/spring.factories:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | org.springframework.nativex.type.NativeConfiguration=\
18 | org.mybatis.spring.nativex.MyBatisThymeleafNativeConfiguration,\
19 | org.mybatis.spring.nativex.MyBatisVelocityNativeConfiguration,\
20 | org.mybatis.spring.nativex.MyBatisFreeMarkerNativeConfiguration,\
21 | org.mybatis.spring.nativex.MyBatisDynamicSqlNativeConfiguration
22 |
--------------------------------------------------------------------------------
/extensions/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3 | "extends": [
4 | "config:recommended"
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/samples/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/cache/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/cache/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/cache/src/main/java/org/mybatis/spring/nativex/sample/cache/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.cache;
17 |
18 | import java.io.Serializable;
19 |
20 | public class City implements Serializable {
21 |
22 | private static final long serialVersionUID = 1L;
23 |
24 | private Integer id;
25 | private String name;
26 | private String state;
27 | private String country;
28 |
29 | public City(Integer id, String name, String state, String country) {
30 | this.id = id;
31 | this.name = name;
32 | this.state = state;
33 | this.country = country;
34 | }
35 |
36 | public Integer getId() {
37 | return id;
38 | }
39 |
40 | public void setId(Integer id) {
41 | this.id = id;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getState() {
53 | return state;
54 | }
55 |
56 | public void setState(String state) {
57 | this.state = state;
58 | }
59 |
60 | public String getCountry() {
61 | return country;
62 | }
63 |
64 | public void setCountry(String country) {
65 | this.country = country;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
71 | + '}';
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/samples/cache/src/main/java/org/mybatis/spring/nativex/sample/cache/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.cache;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.CacheNamespace;
21 | import org.apache.ibatis.annotations.Insert;
22 | import org.apache.ibatis.annotations.Mapper;
23 | import org.apache.ibatis.annotations.Options;
24 | import org.apache.ibatis.annotations.Select;
25 |
26 | @CacheNamespace
27 | @Mapper
28 | public interface CityMapper {
29 |
30 | @Insert("INSERT INTO city (name, state, country) VALUES(#{name}, #{state}, #{country})")
31 | @Options(useGeneratedKeys = true, keyProperty = "id")
32 | void insert(City city);
33 |
34 | @Select("SELECT id, name, state, country FROM city ORDER BY id")
35 | Collection findAll();
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/samples/cache/src/main/java/org/mybatis/spring/nativex/sample/cache/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.cache;
17 |
18 | import java.util.ArrayList;
19 |
20 | import org.slf4j.Logger;
21 | import org.slf4j.LoggerFactory;
22 | import org.springframework.boot.ApplicationRunner;
23 | import org.springframework.boot.SpringApplication;
24 | import org.springframework.boot.autoconfigure.SpringBootApplication;
25 | import org.springframework.context.annotation.Bean;
26 | import org.springframework.nativex.hint.NativeHint;
27 | import org.springframework.nativex.hint.SerializationHint;
28 |
29 | @NativeHint(serializables = @SerializationHint(types = { ArrayList.class, City.class, String.class, Integer.class,
30 | Number.class }))
31 | @SpringBootApplication
32 | public class MybatisSpringNativeSampleApplication {
33 |
34 | private static final Logger log = LoggerFactory.getLogger("ApLog");
35 |
36 | public static void main(String[] args) {
37 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
38 | }
39 |
40 | @Bean
41 | ApplicationRunner runner(CityMapper mapper) {
42 | return args -> {
43 | City newCity = new City(null, "NYC", "NY", "USA");
44 | mapper.insert(newCity);
45 | log.info("New city: {}", newCity);
46 | mapper.findAll().forEach(x -> log.info("{}", x));
47 | mapper.findAll().forEach(x -> log.info("{}", x));
48 | };
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/samples/cache/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | logging.level.org.mybatis.spring.nativex.sample.cache.CityMapper=trace
18 |
--------------------------------------------------------------------------------
/samples/cache/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/cache/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/cache/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [DEBUG] ==> Preparing: INSERT INTO city (name, state, country) VALUES(?, ?, ?)
5 | [DEBUG] ==> Parameters: NYC(String), NY(String), USA(String)
6 | [DEBUG] <== Updates: 1
7 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
8 | [DEBUG] Cache Hit Ratio [org.mybatis.spring.nativex.sample.cache.CityMapper]: 0.0
9 | [DEBUG] ==> Preparing: SELECT id, name, state, country FROM city ORDER BY id
10 | [DEBUG] ==> Parameters:
11 | [TRACE] <== Columns: ID, NAME, STATE, COUNTRY
12 | [TRACE] <== Row: 1, San Francisco, CA, USA
13 | [TRACE] <== Row: 2, Boston, MA, USA
14 | [TRACE] <== Row: 3, Portland, OR, USA
15 | [TRACE] <== Row: 4, NYC, NY, USA
16 | [DEBUG] <== Total: 4
17 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
18 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
19 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
20 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
21 | [DEBUG] Cache Hit Ratio [org.mybatis.spring.nativex.sample.cache.CityMapper]: 0.5
22 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
23 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
24 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
25 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
26 | [INFO] HikariPool-1 - Shutdown initiated...
27 | [INFO] HikariPool-1 - Shutdown completed.
28 |
--------------------------------------------------------------------------------
/samples/configuration/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/configuration/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/java/org/mybatis/spring/nativex/sample/configuration/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.configuration;
17 |
18 | public class City {
19 |
20 | private Integer cityId;
21 | private String cityName;
22 | private String stateCode;
23 | private String countryCode;
24 |
25 | public Integer getCityId() {
26 | return cityId;
27 | }
28 |
29 | public void setCityId(Integer cityId) {
30 | this.cityId = cityId;
31 | }
32 |
33 | public String getCityName() {
34 | return cityName;
35 | }
36 |
37 | public void setCityName(String cityName) {
38 | this.cityName = cityName;
39 | }
40 |
41 | public String getStateCode() {
42 | return stateCode;
43 | }
44 |
45 | public void setStateCode(String stateCode) {
46 | this.stateCode = stateCode;
47 | }
48 |
49 | public String getCountryCode() {
50 | return countryCode;
51 | }
52 |
53 | public void setCountryCode(String countryCode) {
54 | this.countryCode = countryCode;
55 | }
56 |
57 | @Override
58 | public String toString() {
59 | return "City{" + "cityId=" + cityId + ", cityName='" + cityName + '\'' + ", stateCode='" + stateCode + '\''
60 | + ", countryCode='" + countryCode + '\'' + '}';
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/java/org/mybatis/spring/nativex/sample/configuration/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.configuration;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.Insert;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.Select;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @Insert("INSERT INTO city (city_name, state_code, country_code) VALUES(#{cityName}, #{stateCode}, #{countryCode})")
29 | @Options(useGeneratedKeys = true, keyProperty = "cityId")
30 | void insert(City city);
31 |
32 | @Select("SELECT city_id, city_name, state_code, country_code FROM city ORDER BY city_id")
33 | Collection findAll();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/java/org/mybatis/spring/nativex/sample/configuration/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.configuration;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City();
38 | newCity.setCityName("NYC");
39 | newCity.setStateCode("NY");
40 | newCity.setCountryCode("USA");
41 | mapper.insert(newCity);
42 | log.info("New city: {}", newCity);
43 | mapper.findAll().forEach(x -> log.info("{}", x));
44 | };
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | mybatis.configuration.map-underscore-to-camel-case=true
18 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(city_name, state_code, country_code) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(city_name, state_code, country_code) values( 'Boston', 'MA', 'USA');
19 | insert into city(city_name, state_code, country_code) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/configuration/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | city_id INT PRIMARY KEY auto_increment,
19 | city_name VARCHAR,
20 | state_code VARCHAR,
21 | country_code VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/configuration/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{cityId=4, cityName='NYC', stateCode='NY', countryCode='USA'}
5 | [INFO] City{cityId=1, cityName='San Francisco', stateCode='CA', countryCode='USA'}
6 | [INFO] City{cityId=2, cityName='Boston', stateCode='MA', countryCode='USA'}
7 | [INFO] City{cityId=3, cityName='Portland', stateCode='OR', countryCode='USA'}
8 | [INFO] City{cityId=4, cityName='NYC', stateCode='NY', countryCode='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/dao/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/dao/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/dao/src/main/java/org/mybatis/spring/nativex/sample/dao/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.dao;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/dao/src/main/java/org/mybatis/spring/nativex/sample/dao/CityDao.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.dao;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.session.SqlSession;
21 | import org.springframework.stereotype.Component;
22 |
23 | @Component
24 | public class CityDao {
25 |
26 | private final SqlSession sqlSession;
27 |
28 | public CityDao(SqlSession sqlSession) {
29 | this.sqlSession = sqlSession;
30 | }
31 |
32 | public void insert(City city) {
33 | sqlSession.insert("org.mybatis.spring.nativex.sample.dao.CityDao.insert", city);
34 | }
35 |
36 | public Collection findAll() {
37 | return sqlSession.selectList("org.mybatis.spring.nativex.sample.dao.CityDao.findAll");
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/samples/dao/src/main/java/org/mybatis/spring/nativex/sample/dao/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.dao;
17 |
18 | import org.mybatis.spring.nativex.MyBatisResourcesScan;
19 | import org.slf4j.Logger;
20 | import org.slf4j.LoggerFactory;
21 | import org.springframework.boot.ApplicationRunner;
22 | import org.springframework.boot.SpringApplication;
23 | import org.springframework.boot.autoconfigure.SpringBootApplication;
24 | import org.springframework.context.annotation.Bean;
25 |
26 | @MyBatisResourcesScan(typeAliasesPackages = "org.mybatis.spring.nativex.sample.dao", mapperLocationPatterns = "dao/**/*Dao.xml")
27 | @SpringBootApplication
28 | public class MybatisSpringNativeSampleApplication {
29 |
30 | private static final Logger log = LoggerFactory.getLogger("ApLog");
31 |
32 | public static void main(String[] args) {
33 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
34 | }
35 |
36 | @Bean
37 | ApplicationRunner runner(CityDao cityDao) {
38 | return args -> {
39 | City newCity = new City(null, "NYC", "NY", "USA");
40 | cityDao.insert(newCity);
41 | log.info("New city: {}", newCity);
42 | cityDao.findAll().forEach(x -> log.info("{}", x));
43 | };
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/samples/dao/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 | logging.level.org.mybatis.spring.mapper.ClassPathMapperScanner=off
18 |
--------------------------------------------------------------------------------
/samples/dao/src/main/resources/dao/CityDao.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 | INSERT INTO city (name, state, country) VALUES (#{name}, #{state}, #{country})
26 |
27 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/dao/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/dao/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/dao/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/main/java/org/mybatis/spring/nativex/sample/dynamicsql/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.dynamicsql;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/main/java/org/mybatis/spring/nativex/sample/dynamicsql/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.dynamicsql;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City(null, "NYC", "NY", "USA");
38 | mapper.insert(newCity);
39 | log.info("New city: {}", newCity);
40 | mapper.findAll().forEach(x -> log.info("{}", x));
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/dynamic-sql/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/freemarker/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/freemarker/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/java/org/mybatis/spring/nativex/sample/freemarker/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.freemarker;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City() {
26 | // NOP
27 | }
28 |
29 | public City(Integer id, String name, String state, String country) {
30 | this.id = id;
31 | this.name = name;
32 | this.state = state;
33 | this.country = country;
34 | }
35 |
36 | public Integer getId() {
37 | return id;
38 | }
39 |
40 | public void setId(Integer id) {
41 | this.id = id;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getState() {
53 | return state;
54 | }
55 |
56 | public void setState(String state) {
57 | this.state = state;
58 | }
59 |
60 | public String getCountry() {
61 | return country;
62 | }
63 |
64 | public void setCountry(String country) {
65 | this.country = country;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
71 | + '}';
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/java/org/mybatis/spring/nativex/sample/freemarker/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.freemarker;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.InsertProvider;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.SelectProvider;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @InsertProvider
29 | @Options(useGeneratedKeys = true, keyProperty = "id")
30 | void insert(City city);
31 |
32 | @SelectProvider
33 | Collection findAll();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/java/org/mybatis/spring/nativex/sample/freemarker/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.freemarker;
17 |
18 | import org.mybatis.scripting.freemarker.support.TemplateFilePathProvider;
19 | import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
20 | import org.mybatis.spring.nativex.MyBatisResourcesScan;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 | import org.springframework.boot.ApplicationRunner;
24 | import org.springframework.boot.SpringApplication;
25 | import org.springframework.boot.autoconfigure.SpringBootApplication;
26 | import org.springframework.context.annotation.Bean;
27 |
28 | @MyBatisResourcesScan(resourceLocationPatterns = "org/mybatis/spring/nativex/sample/**/*.ftl")
29 | @SpringBootApplication
30 | public class MybatisSpringNativeSampleApplication {
31 |
32 | private static final Logger log = LoggerFactory.getLogger("ApLog");
33 |
34 | public static void main(String[] args) {
35 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
36 | }
37 |
38 | @Bean
39 | ApplicationRunner runner(CityMapper mapper) {
40 | return args -> {
41 | City newCity = new City(null, "NYC", "NY", "USA");
42 | mapper.insert(newCity);
43 | log.info("New city: {}", newCity);
44 | mapper.findAll().forEach(x -> log.info("{}", x));
45 | };
46 | }
47 |
48 | @Bean
49 | ConfigurationCustomizer mybatisConfigurationCustomizer() {
50 | return configuration -> configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/resources/org/mybatis/spring/nativex/sample/freemarker/CityMapper/CityMapper-findAll.ftl:
--------------------------------------------------------------------------------
1 | <#--
2 |
3 | Copyright 2022 the original author or authors.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | https://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | -->
18 | SELECT id, name, state, country
19 | FROM city
20 | ORDER BY id
21 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/resources/org/mybatis/spring/nativex/sample/freemarker/CityMapper/CityMapper-insert.ftl:
--------------------------------------------------------------------------------
1 | <#--
2 |
3 | Copyright 2022 the original author or authors.
4 |
5 | Licensed under the Apache License, Version 2.0 (the "License");
6 | you may not use this file except in compliance with the License.
7 | You may obtain a copy of the License at
8 |
9 | https://www.apache.org/licenses/LICENSE-2.0
10 |
11 | Unless required by applicable law or agreed to in writing, software
12 | distributed under the License is distributed on an "AS IS" BASIS,
13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | See the License for the specific language governing permissions and
15 | limitations under the License.
16 |
17 | -->
18 | INSERT INTO city (name, state, country)
19 | VALUES (<@p name='name'/>, <@p name='state'/>, <@p name='country'/>)
20 |
--------------------------------------------------------------------------------
/samples/freemarker/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/freemarker/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 | 4.0.0
21 |
22 |
23 | org.mybatis.spring.native
24 | mybatis-spring-native
25 | 0.1.0-SNAPSHOT
26 |
27 |
28 | mybatis-spring-native-samples
29 | pom
30 | mybatis-spring-native-samples
31 |
32 |
33 | cache
34 | configuration
35 | dao
36 | dynamic-sql
37 | freemarker
38 | scan
39 | simple
40 | sqlprovider
41 | thymeleaf
42 | thymeleaf-sqlgenerator
43 | velocity
44 | xml
45 |
46 |
47 |
48 | true
49 | true
50 | true
51 | true
52 |
53 | 0.10.6
54 |
55 |
56 |
57 |
58 |
59 | org.mybatis.spring.native
60 | mybatis-spring-native-core
61 | ${project.version}
62 |
63 |
64 | org.mybatis.spring.native
65 | mybatis-spring-native-extensions
66 | ${project.version}
67 |
68 |
69 |
70 |
71 |
72 |
73 | ${project.artifactId}
74 |
75 |
76 |
77 | org.graalvm.buildtools
78 | native-maven-plugin
79 | ${native-buildtools.version}
80 | true
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/samples/scan/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/scan/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/scan/src/main/java/org/mybatis/spring/nativex/sample/external/entity/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.external.entity;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/scan/src/main/java/org/mybatis/spring/nativex/sample/external/mapper/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.external.mapper;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.Mapper;
21 | import org.mybatis.spring.nativex.sample.external.entity.City;
22 |
23 | @Mapper
24 | public interface CityMapper {
25 |
26 | void insert(City city);
27 |
28 | Collection findAll();
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/samples/scan/src/main/java/org/mybatis/spring/nativex/sample/scan/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.scan;
17 |
18 | import org.mybatis.spring.annotation.MapperScan;
19 | import org.mybatis.spring.nativex.MyBatisResourcesScan;
20 | import org.mybatis.spring.nativex.sample.external.entity.City;
21 | import org.mybatis.spring.nativex.sample.external.mapper.CityMapper;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 | import org.springframework.boot.ApplicationRunner;
25 | import org.springframework.boot.SpringApplication;
26 | import org.springframework.boot.autoconfigure.SpringBootApplication;
27 | import org.springframework.context.annotation.Bean;
28 |
29 | @MapperScan(basePackages = "org.mybatis.spring.nativex.sample.external.mapper", sqlSessionTemplateRef = "sqlSessionTemplate")
30 | @MyBatisResourcesScan(typeAliasesPackages = "org.mybatis.spring.nativex.sample.external.entity", mapperLocationPatterns = "mapper/**/*Mapper.xml")
31 | @SpringBootApplication
32 | public class MybatisSpringNativeSampleApplication {
33 |
34 | private static final Logger log = LoggerFactory.getLogger("ApLog");
35 |
36 | public static void main(String[] args) {
37 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
38 | }
39 |
40 | @Bean
41 | ApplicationRunner runner(CityMapper mapper) {
42 | return args -> {
43 | City newCity = new City(null, "NYC", "NY", "USA");
44 | mapper.insert(newCity);
45 | log.info("New city: {}", newCity);
46 | mapper.findAll().forEach(x -> log.info("{}", x));
47 | };
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/samples/scan/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/scan/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/scan/src/main/resources/mapper/CityMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 | INSERT INTO city (name, state, country) VALUES (#{name}, #{state}, #{country})
26 |
27 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/scan/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/scan/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/simple/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/simple/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/simple/src/main/java/org/mybatis/spring/nativex/sample/simple/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.simple;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/simple/src/main/java/org/mybatis/spring/nativex/sample/simple/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.simple;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.Insert;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.Select;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @Insert("INSERT INTO city (name, state, country) VALUES(#{name}, #{state}, #{country})")
29 | @Options(useGeneratedKeys = true, keyProperty = "id")
30 | void insert(City city);
31 |
32 | @Select("SELECT id, name, state, country FROM city ORDER BY id")
33 | Collection findAll();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/samples/simple/src/main/java/org/mybatis/spring/nativex/sample/simple/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.simple;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City(null, "NYC", "NY", "USA");
38 | mapper.insert(newCity);
39 | log.info("New city: {}", newCity);
40 | mapper.findAll().forEach(x -> log.info("{}", x));
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/samples/simple/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/simple/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/simple/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/simple/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/sqlprovider/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/sqlprovider/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/java/org/mybatis/spring/nativex/sample/sqlprovider/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.sqlprovider;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/java/org/mybatis/spring/nativex/sample/sqlprovider/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.sqlprovider;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.InsertProvider;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.SelectProvider;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @InsertProvider(InsertSqlProvider.class)
29 | @Options(useGeneratedKeys = true, keyProperty = "id")
30 | void insert(City city);
31 |
32 | @SelectProvider(type = SelectSqlProvider.class, method = "provideSqlForFindAll")
33 | Collection findAll();
34 |
35 | class InsertSqlProvider {
36 | private InsertSqlProvider() {
37 | // NOP
38 | }
39 |
40 | @SuppressWarnings({ "java:S3400", "unused" })
41 | public static String provideSql() {
42 | return "INSERT INTO city (name, state, country) VALUES(#{name}, #{state}, #{country})";
43 | }
44 | }
45 |
46 | class SelectSqlProvider {
47 | private SelectSqlProvider() {
48 | // NOP
49 | }
50 |
51 | @SuppressWarnings({ "java:S3400", "unused" })
52 | public static String provideSqlForFindAll() {
53 | return "SELECT id, name, state, country FROM city ORDER BY id";
54 | }
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/java/org/mybatis/spring/nativex/sample/sqlprovider/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.sqlprovider;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City(null, "NYC", "NY", "USA");
38 | mapper.insert(newCity);
39 | log.info("New city: {}", newCity);
40 | mapper.findAll().forEach(x -> log.info("{}", x));
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/sqlprovider/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/sqlprovider/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/java/org/mybatis/spring/nativex/sample/thymeleaf/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.thymeleaf;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City() {
26 | // NOP
27 | }
28 |
29 | public City(Integer id, String name, String state, String country) {
30 | this.id = id;
31 | this.name = name;
32 | this.state = state;
33 | this.country = country;
34 | }
35 |
36 | public Integer getId() {
37 | return id;
38 | }
39 |
40 | public void setId(Integer id) {
41 | this.id = id;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getState() {
53 | return state;
54 | }
55 |
56 | public void setState(String state) {
57 | this.state = state;
58 | }
59 |
60 | public String getCountry() {
61 | return country;
62 | }
63 |
64 | public void setCountry(String country) {
65 | this.country = country;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
71 | + '}';
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/java/org/mybatis/spring/nativex/sample/thymeleaf/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.thymeleaf;
17 |
18 | import org.mybatis.scripting.thymeleaf.SqlGenerator;
19 | import org.mybatis.scripting.thymeleaf.SqlGeneratorConfig;
20 | import org.mybatis.scripting.thymeleaf.processor.BindVariableRender;
21 | import org.mybatis.spring.nativex.MyBatisResourcesScan;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 | import org.springframework.boot.ApplicationRunner;
25 | import org.springframework.boot.SpringApplication;
26 | import org.springframework.boot.autoconfigure.SpringBootApplication;
27 | import org.springframework.context.annotation.Bean;
28 | import org.springframework.jdbc.core.BeanPropertyRowMapper;
29 | import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;
30 | import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
31 | import org.springframework.jdbc.support.GeneratedKeyHolder;
32 | import org.springframework.jdbc.support.KeyHolder;
33 |
34 | @MyBatisResourcesScan(reflectionTypePackages = "org.mybatis.spring.nativex.sample.thymeleaf", resourceLocationPatterns = "sqls/**/*.sql")
35 | @SpringBootApplication
36 | public class MybatisSpringNativeSampleApplication {
37 |
38 | private static final Logger log = LoggerFactory.getLogger("ApLog");
39 |
40 | public static void main(String[] args) {
41 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
42 | }
43 |
44 | @Bean
45 | ApplicationRunner runner(NamedParameterJdbcOperations operations, SqlGenerator sqlGenerator) {
46 | return args -> {
47 | City newCity = new City(null, "NYC", "NY", "USA");
48 | KeyHolder keyHolder = new GeneratedKeyHolder();
49 | operations.update(sqlGenerator.generate("sqls/city/city-insert.sql", newCity),
50 | new BeanPropertySqlParameterSource(newCity), keyHolder);
51 | newCity.setId(keyHolder.getKeyAs(Integer.class));
52 | log.info("New city: {}", newCity);
53 | operations
54 | .query(sqlGenerator.generate("sqls/city/city-findAll.sql", null), new BeanPropertyRowMapper<>(City.class))
55 | .forEach(x -> log.info("{}", x));
56 | };
57 | }
58 |
59 | @Bean
60 | SqlGenerator sqlGenerator() {
61 | return new SqlGenerator(SqlGeneratorConfig.newInstanceWithCustomizer(
62 | c -> c.getDialect().setBindVariableRender(BindVariableRender.BuiltIn.SPRING_NAMED_PARAMETER.getType())));
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/resources/sqls/city/city-findAll.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | SELECT id, name, state, country
18 | FROM city
19 | ORDER BY id
20 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/main/resources/sqls/city/city-insert.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | INSERT INTO city (name, state, country)
18 | VALUES (/*[# mb:p="name"]*/ 'San Francisco' /*[/]*/, /*[# mb:p="state"]*/ 'CA' /*[/]*/, /*[# mb:p="country"]*/ 'USA' /*[/]*/)
19 |
--------------------------------------------------------------------------------
/samples/thymeleaf-sqlgenerator/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/thymeleaf/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/thymeleaf/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/java/org/mybatis/spring/nativex/sample/thymeleaf/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.thymeleaf;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City() {
26 | // NOP
27 | }
28 |
29 | public City(Integer id, String name, String state, String country) {
30 | this.id = id;
31 | this.name = name;
32 | this.state = state;
33 | this.country = country;
34 | }
35 |
36 | public Integer getId() {
37 | return id;
38 | }
39 |
40 | public void setId(Integer id) {
41 | this.id = id;
42 | }
43 |
44 | public String getName() {
45 | return name;
46 | }
47 |
48 | public void setName(String name) {
49 | this.name = name;
50 | }
51 |
52 | public String getState() {
53 | return state;
54 | }
55 |
56 | public void setState(String state) {
57 | this.state = state;
58 | }
59 |
60 | public String getCountry() {
61 | return country;
62 | }
63 |
64 | public void setCountry(String country) {
65 | this.country = country;
66 | }
67 |
68 | @Override
69 | public String toString() {
70 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
71 | + '}';
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/java/org/mybatis/spring/nativex/sample/thymeleaf/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.thymeleaf;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.InsertProvider;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.SelectProvider;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @InsertProvider
29 | @Options(useGeneratedKeys = true, keyProperty = "id")
30 | void insert(City city);
31 |
32 | @SelectProvider
33 | Collection findAll();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/java/org/mybatis/spring/nativex/sample/thymeleaf/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.thymeleaf;
17 |
18 | import org.mybatis.scripting.thymeleaf.support.TemplateFilePathProvider;
19 | import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
20 | import org.mybatis.spring.nativex.MyBatisResourcesScan;
21 | import org.slf4j.Logger;
22 | import org.slf4j.LoggerFactory;
23 | import org.springframework.boot.ApplicationRunner;
24 | import org.springframework.boot.SpringApplication;
25 | import org.springframework.boot.autoconfigure.SpringBootApplication;
26 | import org.springframework.context.annotation.Bean;
27 |
28 | @MyBatisResourcesScan(resourceLocationPatterns = "org/mybatis/spring/nativex/sample/**/*.sql")
29 | @SpringBootApplication
30 | public class MybatisSpringNativeSampleApplication {
31 |
32 | private static final Logger log = LoggerFactory.getLogger("ApLog");
33 |
34 | public static void main(String[] args) {
35 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
36 | }
37 |
38 | @Bean
39 | ApplicationRunner runner(CityMapper mapper) {
40 | return args -> {
41 | City newCity = new City(null, "NYC", "NY", "USA");
42 | mapper.insert(newCity);
43 | log.info("New city: {}", newCity);
44 | mapper.findAll().forEach(x -> log.info("{}", x));
45 | };
46 | }
47 |
48 | @Bean
49 | ConfigurationCustomizer mybatisConfigurationCustomizer() {
50 | return configuration -> configuration.setDefaultSqlProviderType(TemplateFilePathProvider.class);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/resources/org/mybatis/spring/nativex/sample/thymeleaf/CityMapper/CityMapper-findAll.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | SELECT id, name, state, country
18 | FROM city
19 | ORDER BY id
20 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/resources/org/mybatis/spring/nativex/sample/thymeleaf/CityMapper/CityMapper-insert.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | INSERT INTO city (name, state, country)
18 | VALUES (/*[# mb:p="name"]*/ 'San Francisco' /*[/]*/, /*[# mb:p="state"]*/ 'CA' /*[/]*/, /*[# mb:p="country"]*/ 'USA' /*[/]*/)
19 |
--------------------------------------------------------------------------------
/samples/thymeleaf/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/thymeleaf/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/velocity/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/velocity/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/java/org/mybatis/spring/nativex/sample/velocity/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.velocity;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/java/org/mybatis/spring/nativex/sample/velocity/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.velocity;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.Insert;
21 | import org.apache.ibatis.annotations.Mapper;
22 | import org.apache.ibatis.annotations.Options;
23 | import org.apache.ibatis.annotations.Select;
24 |
25 | @Mapper
26 | public interface CityMapper {
27 |
28 | @Insert("INSERT INTO city (name, state, country) VALUES(@{name}, @{state}, @{country})")
29 | @Options(useGeneratedKeys = true, keyProperty = "id")
30 | void insert(City city);
31 |
32 | @Select("SELECT id, name, state, country FROM city ORDER BY id")
33 | Collection findAll();
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/java/org/mybatis/spring/nativex/sample/velocity/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.velocity;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City(null, "NYC", "NY", "USA");
38 | mapper.insert(newCity);
39 | log.info("New city: {}", newCity);
40 | mapper.findAll().forEach(x -> log.info("{}", x));
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/velocity/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/velocity/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------
/samples/xml/LICENSE_HEADER:
--------------------------------------------------------------------------------
1 | Copyright ${license.git.copyrightYears} the original author or authors.
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | https://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
14 |
--------------------------------------------------------------------------------
/samples/xml/format.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/samples/xml/src/main/java/org/mybatis/spring/nativex/sample/xml/City.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.xml;
17 |
18 | public class City {
19 |
20 | private Integer id;
21 | private String name;
22 | private String state;
23 | private String country;
24 |
25 | public City(Integer id, String name, String state, String country) {
26 | this.id = id;
27 | this.name = name;
28 | this.state = state;
29 | this.country = country;
30 | }
31 |
32 | public Integer getId() {
33 | return id;
34 | }
35 |
36 | public void setId(Integer id) {
37 | this.id = id;
38 | }
39 |
40 | public String getName() {
41 | return name;
42 | }
43 |
44 | public void setName(String name) {
45 | this.name = name;
46 | }
47 |
48 | public String getState() {
49 | return state;
50 | }
51 |
52 | public void setState(String state) {
53 | this.state = state;
54 | }
55 |
56 | public String getCountry() {
57 | return country;
58 | }
59 |
60 | public void setCountry(String country) {
61 | this.country = country;
62 | }
63 |
64 | @Override
65 | public String toString() {
66 | return "City{" + "id=" + id + ", name='" + name + '\'' + ", state='" + state + '\'' + ", country='" + country + '\''
67 | + '}';
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/samples/xml/src/main/java/org/mybatis/spring/nativex/sample/xml/CityMapper.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.xml;
17 |
18 | import java.util.Collection;
19 |
20 | import org.apache.ibatis.annotations.Mapper;
21 |
22 | @Mapper
23 | public interface CityMapper {
24 |
25 | void insert(City city);
26 |
27 | Collection findAll();
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/samples/xml/src/main/java/org/mybatis/spring/nativex/sample/xml/MybatisSpringNativeSampleApplication.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * https://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.mybatis.spring.nativex.sample.xml;
17 |
18 | import org.slf4j.Logger;
19 | import org.slf4j.LoggerFactory;
20 | import org.springframework.boot.ApplicationRunner;
21 | import org.springframework.boot.SpringApplication;
22 | import org.springframework.boot.autoconfigure.SpringBootApplication;
23 | import org.springframework.context.annotation.Bean;
24 |
25 | @SpringBootApplication
26 | public class MybatisSpringNativeSampleApplication {
27 |
28 | private static final Logger log = LoggerFactory.getLogger("ApLog");
29 |
30 | public static void main(String[] args) {
31 | SpringApplication.run(MybatisSpringNativeSampleApplication.class, args);
32 | }
33 |
34 | @Bean
35 | ApplicationRunner runner(CityMapper mapper) {
36 | return args -> {
37 | City newCity = new City(null, "NYC", "NY", "USA");
38 | mapper.insert(newCity);
39 | log.info("New city: {}", newCity);
40 | mapper.findAll().forEach(x -> log.info("{}", x));
41 | };
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/samples/xml/src/main/resources/application.properties:
--------------------------------------------------------------------------------
1 | #
2 | # Copyright 2022 the original author or authors.
3 | #
4 | # Licensed under the Apache License, Version 2.0 (the "License");
5 | # you may not use this file except in compliance with the License.
6 | # You may obtain a copy of the License at
7 | #
8 | # https://www.apache.org/licenses/LICENSE-2.0
9 | #
10 | # Unless required by applicable law or agreed to in writing, software
11 | # distributed under the License is distributed on an "AS IS" BASIS,
12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | # See the License for the specific language governing permissions and
14 | # limitations under the License.
15 | #
16 |
17 |
--------------------------------------------------------------------------------
/samples/xml/src/main/resources/data.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | insert into city(name, state, country) values( 'San Francisco', 'CA', 'USA');
18 | insert into city(name, state, country) values( 'Boston', 'MA', 'USA');
19 | insert into city(name, state, country) values( 'Portland', 'OR', 'USA');
20 |
--------------------------------------------------------------------------------
/samples/xml/src/main/resources/org/mybatis/spring/nativex/sample/xml/CityMapper.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
22 |
23 |
24 |
25 | INSERT INTO city (name, state, country) VALUES (#{name}, #{state}, #{country})
26 |
27 |
28 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/samples/xml/src/main/resources/schema.sql:
--------------------------------------------------------------------------------
1 | --
2 | -- Copyright 2022 the original author or authors.
3 | --
4 | -- Licensed under the Apache License, Version 2.0 (the "License");
5 | -- you may not use this file except in compliance with the License.
6 | -- You may obtain a copy of the License at
7 | --
8 | -- https://www.apache.org/licenses/LICENSE-2.0
9 | --
10 | -- Unless required by applicable law or agreed to in writing, software
11 | -- distributed under the License is distributed on an "AS IS" BASIS,
12 | -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | -- See the License for the specific language governing permissions and
14 | -- limitations under the License.
15 | --
16 |
17 | CREATE TABLE city (
18 | id INT PRIMARY KEY auto_increment,
19 | name VARCHAR,
20 | state VARCHAR,
21 | country VARCHAR
22 | );
--------------------------------------------------------------------------------
/samples/xml/src/test/resources/expected-console.log:
--------------------------------------------------------------------------------
1 | [INFO] AOT mode enabled
2 | [INFO] HikariPool-1 - Starting...
3 | [INFO] HikariPool-1 - Start completed.
4 | [INFO] New city: City{id=4, name='NYC', state='NY', country='USA'}
5 | [INFO] City{id=1, name='San Francisco', state='CA', country='USA'}
6 | [INFO] City{id=2, name='Boston', state='MA', country='USA'}
7 | [INFO] City{id=3, name='Portland', state='OR', country='USA'}
8 | [INFO] City{id=4, name='NYC', state='NY', country='USA'}
9 | [INFO] HikariPool-1 - Shutdown initiated...
10 | [INFO] HikariPool-1 - Shutdown completed.
11 |
--------------------------------------------------------------------------------