Compare commits

...
Author SHA1 Message Date
Rob Bygrave 8edaabf755 [maven-release-plugin] prepare release ebean-parent-12.14.1 2022-01-17 22:30:53 +13:00
Rob Bygrave 25eea42211 Bump to ebean-migration 12.13.0 and ebean-agent 12.14.1 2022-01-17 22:28:36 +13:00
Rob Bygrave 263f6cdeba Tidy OraclePlatform only 2022-01-17 22:10:53 +13:00
Rob Bygrave 38f1967e60 #2473 - Oracle - column alias - Change such that OraclePlatform doesn't use column alias
So with #2254 we regressed OraclePlatform to use column alias. This really should have introduced an Oracle12 platform instead. 18c onwards and we don't want the column alias.
2022-01-17 22:10:21 +13:00
Rob Bygrave 6eb8eb0dd2 #2473 Tidy BasicSqlAnsiLimiter only, no functional change 2022-01-17 21:58:33 +13:00
Rob Bygrave 1165d857d8 Fix test ParentQueryTest 2022-01-17 21:57:14 +13:00
Rob Bygrave 874c2f5231 #2492 - Fix for Oracle platform when insert only default values 2022-01-17 21:42:09 +13:00
Rob Bygrave 88ab852855 No real change, tidy DbExpressionHandlerFactory only 2022-01-17 21:28:45 +13:00
Rob Bygrave b577331524 #2492 - Fix for Oracle platform when insert only default values 2022-01-17 21:27:42 +13:00
Rob Bygrave ec45fc1c86 Fix tests for Oracle - BITADD in @Where clause expression 2022-01-17 21:26:19 +13:00
Rob Bygrave e65876e8ed #2477 - Add failing test case (disable for the moment) 2022-01-17 20:58:19 +13:00
Rob BygraveandGitHub 5453037172 Merge pull request #2491 from ebean-orm/feature/2476-elementCollectionConstructor
#2476 - Fix for element collection on bean with default constructor
2022-01-17 15:41:33 +13:00
Rob Bygrave 9b116c9bf6 #2476 - tidy tests 2022-01-17 15:38:41 +13:00
Rob Bygrave 82862deccc #2476 - Fix for element collection on bean with default constructor
Note that we can look for a better longer term fix which might would look at treating element collection more like ToMany collections in terms of enhancement.
2022-01-17 15:36:26 +13:00
Rob Bygrave 1c83bbe0b0 #2476 - Failing test for element collection on bean with default constructor 2022-01-17 15:33:13 +13:00
Rob BygraveandGitHub f16f34f35f Merge pull request #2488 from ebean-orm/feature/2487
#2487 - ebean-test support Docker In Docker - docker container's hostname rather than hardcoded "localhost"
2022-01-14 16:32:04 +13:00
Rob Bygrave 38bc5b2fea #2488 - refactor extract logic into DockerHost helper, fix RedisSetup, pass docker host to ebean-test-docker 2022-01-14 16:27:04 +13:00
Rob Bygrave 356dc5eb19 #2487 - ebean-test support Docker In Docker - docker container's hostname rather than hardcoded "localhost" 2022-01-13 15:02:38 +13:00
Rob BygraveandGitHub c5779133bc Merge pull request #2485 from FOCONIS/fix-utf8-problems-with-specialchars
Fix utf8 problems with specialchars
2022-01-13 11:05:27 +13:00
Rob BygraveandGitHub b8b6311348 Merge pull request #2447 from FOCONIS/fix-scalartype-problem2
Traverse class hierarchy, when searching for ScalarType
2022-01-13 10:58:05 +13:00
FOCONIS\szemenyei 8eed983fbb restore old test 2022-01-12 08:37:46 +01:00
Rob BygraveandGitHub 7cfecb83a9 Merge pull request #2486 from bigjimlefou/fixWindows
Fix some tests failing on Windows
2022-01-12 09:17:37 +13:00
bigjimlefou e92939a34d Fix failing test on Windows platform 2022-01-11 15:41:20 +01:00
bigjimlefou 408b982eb3 Use of platform-specific specific file separator 2022-01-11 15:41:19 +01:00
bigjimlefou dd7e7711a8 Use of platform-specific specific file separator 2022-01-11 15:41:19 +01:00
bigjimlefou 5a3f7853a6 Fix failing test on Windows platform. 2022-01-11 15:41:19 +01:00
Roland PramlandFOCONIS\szemenyei 01847e44de Always use UTF-8 2022-01-11 10:11:13 +01:00
FOCONIS\szemenyei 0cf9f0bf58 Revert "at first revert solution"
This reverts commit b01b44af10.
2022-01-11 09:49:02 +01:00
FOCONIS\szemenyei b01b44af10 at first revert solution 2022-01-11 09:48:47 +01:00
FOCONIS\szemenyei 8d85000970 Fix Checksum calculate() with special characters
(cherry picked from commit e9efd5a702)
2022-01-11 09:47:44 +01:00
Jonas Pöhler e7f9c63502 Clear up some possible confusion in the test 2022-01-05 15:46:34 +01:00
Jonas Pöhler eb21b41fba Refactor and fixes for interfaces (like Path) + extend existing tests 2022-01-05 14:22:24 +01:00
Jonas Pöhler 3dc6c567a0 Merge remote-tracking branch 'ebean/master' into fix-scalartype-problem2 2022-01-05 13:34:29 +01:00
Rob BygraveandGitHub 18eed47306 Merge pull request #2475 from bigjimlefou/fixLocale
Fix locale problem with TestCsvReader and TestCsvReaderWithCallback.
2021-12-24 11:10:05 +13:00
Cédric Sougné 9ddf1333ed Fix locale problem with TestCsvReader and TestCsvReaderWithCallback. 2021-12-23 17:19:44 +01:00
Rob Bygrave 73896d375f Bump test modules to 12.14.1-SNAPSHOT after release 2021-12-20 16:49:18 +13:00
Rob Bygrave 3f645211a6 [maven-release-plugin] prepare for next development iteration 2021-12-20 16:34:23 +13:00
Rob Bygrave 451e2fa93c [maven-release-plugin] prepare release ebean-parent-12.14.0 2021-12-20 16:34:17 +13:00
Rob Bygrave 2ff3b0acb7 Update gitflow cron schedule for mariadb, sqlserver, jdk-18 2021-12-20 16:20:08 +13:00
tFellnerandGitHub 42594533da Support for Sequences in MariaDB (#2304)
* Support for Sequneces in MariaDB

* clean up readSequenceValue in test class

* remove flakiness

* remove change for later discussion

* replace deprecated methods

* strictly allow sequences
2021-12-20 16:11:30 +13:00
Rob Bygrave 678494f331 Bump version of logback used in tests only 2021-12-20 16:09:33 +13:00
Rob Bygrave 361df6732a #2472 - BeanPersistController and isCascade() for delete requests (following #2458) 2021-12-20 15:49:58 +13:00
Rob Bygrave c3320f4a0b Bump version to 12.14.0-SNAPSHOT 2021-12-20 13:14:34 +13:00
Rob Bygrave c411d9a665 Bump version to 12.14.0-SNAPSHOT 2021-12-20 12:47:36 +13:00
Rob Bygrave 8ea2c31076 #2471 - Bump avaje-config to 1.7 (from 1.5) with removed jndi lookup for DataSource 2021-12-20 12:45:30 +13:00
Rob Bygrave 254b0df16b #2470 - Bump jedis to version 3.8.0 (from 3.6.3) 2021-12-20 12:40:41 +13:00
Rob Bygrave c0f4451d20 Fix pom versions in test only modules after release 2021-12-20 10:47:26 +13:00
Rob BygraveandGitHub 6c544a2835 Merge pull request #2468 from FOCONIS/pr/fix/jdbc_url_sqlserver_tests
Unify JDBC URL for SqlServer (analog to testconfig-files)
2021-12-20 10:29:58 +13:00
Rob BygraveandGitHub 227d18bbf0 Merge pull request #2469 from FOCONIS/pr/enh/helper_methods_annotation_util
Add metaHas and metaFindAll in AnnotationUtil
2021-12-20 10:28:32 +13:00
Rob BygraveandGitHub 18cdd2ed7a Merge pull request #2466 from FOCONIS/pr/fix/remove_unused_load_error_handler
Remove unused LoadErrorHandler interface
2021-12-20 10:27:14 +13:00
Jonas Pöhler 91d1fb8cea ADD: javadoc 2021-12-17 15:10:30 +01:00
Jonas Pöhler 058021f8d0 ADD: metaHas and metaFindAll as functional sugar 2021-12-17 13:56:08 +01:00
Roland PramlandJonas Pöhler f4d270e8b5 FIX: JDBC URL for SqlServer (similar to testconfig-files) 2021-12-17 13:26:00 +01:00
Jonas Pöhler 7b8052c097 Merge remote-tracking branch 'ebean/master' into pr/fix/remove_unused_load_error_handler 2021-12-17 13:22:46 +01:00
Rob Bygrave 68b7deba9d Put back h2database to 1.4.199 as 2.x breaks way too many things, need to work on that 2021-12-17 23:25:49 +13:00
Roland PramlandJonas Pöhler 65e924feaa Deleted obsolete LoadErrorHandler 2021-12-17 10:44:42 +01:00
Rob Bygrave 6cc5e83b01 Merge branch 'master' of github.com:ebean-orm/ebean 2021-12-17 21:47:17 +13:00
Rob Bygrave 752d5d4782 Remove pom.xml.releaseBackup from barfed release 2021-12-17 21:47:07 +13:00
Rob BygraveandGitHub 20fdbfc972 Merge pull request #2463 from ebean-orm/dependabot/maven/ebean-test/com.h2database-h2-2.0.202
Bump h2 from 1.4.199 to 2.0.202 in /ebean-test
2021-12-17 21:44:21 +13:00
Rob Bygrave bd01dfd29a Bump parent pom, moved to s01.oss.sonatype.org 2021-12-17 20:57:46 +13:00
Rob Bygrave 6a9b5944a3 Remove release.properties that somehow got into git after release 2021-12-17 20:55:19 +13:00
dependabot[bot]andGitHub 6e31de6f2e Bump h2 from 1.4.199 to 2.0.202 in /ebean-test
Bumps [h2](https://github.com/h2database/h2database) from 1.4.199 to 2.0.202.
- [Release notes](https://github.com/h2database/h2database/releases)
- [Commits](https://github.com/h2database/h2database/compare/version-1.4.199...version-2.0.202)

---
updated-dependencies:
- dependency-name: com.h2database:h2
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-12-17 04:33:53 +00:00
Rob Bygrave 5fddc37037 [maven-release-plugin] prepare for next development iteration 2021-12-17 17:26:43 +13:00
Rob Bygrave ca6e3963db [maven-release-plugin] prepare release ebean-parent-12.13.2 2021-12-17 17:26:36 +13:00
Rob BygraveandGitHub a966557b68 Merge pull request #2459 from ebean-orm/feature/2458-isCascade
#2458 - Add BeanPersistController.isCascade() to identify cascade vs "top level" persist requests
2021-12-17 10:54:19 +13:00
Rob Bygrave 1a6a426683 #2458 - Add BeanPersistController.isCascade() to identify cascade vs "top level" persist requests 2021-12-17 10:43:27 +13:00
Rob Bygrave dd43fe4db3 Update pom in ebean-kotlin empty module to use java 1.8 2021-12-15 21:49:34 +13:00
Rob Bygrave b4ebeb0070 #2445 - update test generated ddl as part of ... Put back DB2 maxTableNameLength=18, maxConstraintNameLength=18 2021-12-15 21:49:02 +13:00
Rob Bygrave 0dbf982293 Javadoc only update in PlatformConfig 2021-12-15 21:47:58 +13:00
Rob BygraveandGitHub 12d7184f02 Merge pull request #2454 from ebean-orm/feature/2445-revert-maxTableNameLength
#2445 - Put back DB2 maxTableNameLength=18, maxConstraintNameLength=18
2021-12-14 10:24:59 +13:00
Rob Bygrave c3295f1145 #2445 - Put back DB2 maxTableNameLength=18, maxConstraintNameLength=18 2021-12-13 20:54:49 +13:00
Rob Bygrave 9bdcd6c55e #2452 - server-wide defaultJsonMutation SOURCE is not honored by DbJson scalar types (e.g. List<String>) 2021-12-07 18:13:17 +13:00
Rob Bygrave b627794f8f #2451 - Initial add of ebean-kotlin module, home of kotlin extension 2021-12-07 16:25:46 +13:00
Rob Bygrave b9f3ff24e9 Tidy test only - BasicProfileLocationTest 2021-12-07 15:25:02 +13:00
Rob Bygrave 9752eced1f Adjust tests for JDK 18-ea build 2021-12-07 15:24:19 +13:00
Rob Bygrave e7aa1fdac5 Update badges on README 2021-12-07 15:21:43 +13:00
Rob Bygrave 9d26ab2103 Adjust tests for JDK 18-ea build 2021-12-07 15:15:21 +13:00
Rob Bygrave 103f965182 Add github workflow for JDK 18-ea build 2021-12-07 14:51:53 +13:00
Rob Bygrave d28d9a6176 Follow up to #2448 - Fix maven warning 2021-12-07 14:47:49 +13:00
Rob BygraveandGitHub 173b81a64b Merge pull request #2448 from FOCONIS/fix-pom
Fix maven warning
2021-12-07 14:43:03 +13:00
Rob BygraveandGitHub 135b1e3b57 Merge pull request #2450 from carldea/master
Using TCK Tested JDK builds of OpenJDK Making the switch to Zulu
2021-12-07 14:20:57 +13:00
Carl DeaandGitHub 888109d706 Using TCK Tested JDK builds of OpenJDK
The AdoptOpenJDK has been discontinued since July 2021 (https://adoptopenjdk.net). Switching the distribution to Azul Zulu. When using Zulu you get all the latest updated (TCK Tested) builds for all versions of OpenJDK.
2021-12-06 15:00:49 -05:00
Carl DeaandGitHub 8cd6d50def Using TCK Tested JDK builds of OpenJDK
The AdoptOpenJDK has been discontinued since July 2021 (https://adoptopenjdk.net). Switching the distribution to Azul Zulu. When using Zulu you get all the latest updated (TCK Tested) builds for all versions of OpenJDK
2021-12-06 14:59:41 -05:00
Roland Praml 272b316ecc some more changes 2021-12-02 11:29:45 +01:00
Roland Praml e95edad04b Fix maven warning 2021-12-02 11:23:38 +01:00
Roland Praml f830662cce Improve TypeManager - cache typeNotFound information. 2021-12-02 11:18:22 +01:00
Roland Praml 84ac737ceb ADD: Testcase for Calendar 2021-12-02 10:42:49 +01:00
Roland Praml 483f0398b2 Fix: 'No ScalarType registered for class java.util.GregorianCalendar' - check all registered scalar type if no exact match was found 2021-12-02 08:30:24 +01:00
Rob Bygrave d934d44164 update README adding more badges 2021-12-01 22:14:11 +13:00
Rob Bygrave a2ad1aaf6e update test github workflows 2021-12-01 17:51:04 +13:00
Rob Bygrave a0b6a13e6c update test github workflows for sqlserver and mariadb 2021-12-01 17:27:26 +13:00
Rob Bygrave a65340b939 update test github workflows for sqlserver and mariadb 2021-12-01 17:26:24 +13:00
Rob Bygrave 0279f8b1ad add some test github workflows for sqlserver and mariadb 2021-12-01 16:02:32 +13:00
Rob Bygrave bd2faed6a0 Update readme add badge for multi-jdk build 2021-12-01 15:54:01 +13:00
Rob Bygrave a0e2155ec2 add github workflow multi-jdk-build.yml 2021-12-01 15:44:17 +13:00
Rob Bygrave 5ff9171aaf Bump kotlin version to test against, use maven profiles for test module activation 2021-12-01 15:41:04 +13:00
Rob Bygrave 4d7936c1a6 add mariadb to multi-platform-test.yml 2021-12-01 13:54:55 +13:00
Rob Bygrave 552145db37 add sqlserver 2019 and 2017 testing to multi-platform-test.yml - adjust port for 2017 2021-12-01 13:17:54 +13:00
Rob Bygrave 0504cdc2d8 add sqlserver 2019 and 2017 testing to multi-platform-test.yml 2021-12-01 13:00:36 +13:00
Rob Bygrave a380b609cd add git workflow multi-platform-test 2021-12-01 09:55:22 +13:00
Rob Bygrave 65ac083872 add git workflow multi-platform-test 2021-12-01 09:52:59 +13:00
Rob Bygrave a82dca24da changed generated migrations from db2 change in #2445 2021-12-01 09:52:39 +13:00
Rob BygraveandGitHub 466a616f3e Merge pull request #2445 from FOCONIS/improve-testing
Improve testing, add DB2 Docker testing support to ebean-test
2021-12-01 09:35:45 +13:00
Rob BygraveandGitHub a0552387f8 Merge pull request #2446 from FOCONIS/fix-count-distinc-order-no-ordering
NPE Fix with .setCountDistinct(CountDistinctOrder.NO_ORDERING)
2021-12-01 09:28:54 +13:00
Noemi Szemenyei 25bc0e947d NPE Fix with .setCountDistinct(CountDistinctOrder.NO_ORDERING) 2021-11-30 10:21:34 +01:00
Roland Praml f8253a1252 add ebean-test properties for various containers and adjusted documentation 2021-11-26 15:32:11 +01:00
Roland Praml 2581d82cff FIX: Sqlite does not support ResultSetConcurrencyModeUpdatable 2021-11-26 15:02:46 +01:00
Roland Praml 331ea90e14 Fix: Support conversion of varchar[](300) array type for Clickhouse 2021-11-26 15:02:01 +01:00
Roland Praml dfb1d6ab54 ADD: Db2 container support 2021-11-26 15:01:15 +01:00
Roland Praml 067f4bfdea ADD JDBC-drivers to POM 2021-11-26 14:55:28 +01:00
Rob Bygrave 0a71ad624e [maven-release-plugin] prepare for next development iteration 2021-11-26 21:57:10 +13:00
139 changed files with 2069 additions and 569 deletions
+1 -1
View File
@@ -22,7 +22,7 @@ jobs:
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
distribution: 'zulu'
- name: Maven cache
uses: actions/cache@v2
env:
+39
View File
@@ -0,0 +1,39 @@
name: JDK 18-ea
on:
workflow_dispatch:
schedule:
- cron: '30 6 * * 1,3,5'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [18-ea]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'zulu'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Build with Maven
run: mvn package
+38
View File
@@ -0,0 +1,38 @@
name: MariaDB 10.6
on:
workflow_dispatch:
schedule:
- cron: '10 7 * * 1,4'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: mariadb 10.6
run: mvn clean test -Dprops.file=testconfig/ebean-mariadb.properties
+39
View File
@@ -0,0 +1,39 @@
name: Multi-JDK Build
on:
workflow_dispatch:
schedule:
- cron: '30 6 * * *'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [8.0.192, 8, 11.0.3, 11, 17]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'zulu'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: Build with Maven
run: mvn package
+45
View File
@@ -0,0 +1,45 @@
name: Multi-database platform test
on: [workflow_dispatch]
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: h2
run: mvn clean test
- name: postgres
run: mvn clean test -Dprops.file=testconfig/ebean-postgres.properties
- name: mysql
run: mvn clean test -Dprops.file=testconfig/ebean-mysql.properties
- name: sqlserver 2019
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver19.properties
- name: sqlserver 2017
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver17.properties
- name: mariadb
run: mvn clean test -Dprops.file=testconfig/ebean-mariadb.properties
+38
View File
@@ -0,0 +1,38 @@
name: MySql
on:
workflow_dispatch:
schedule:
- cron: '20 6 * * *'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: mysql
run: mvn clean test -Dprops.file=testconfig/ebean-mysql.properties
+38
View File
@@ -0,0 +1,38 @@
name: Postgres
on:
workflow_dispatch:
schedule:
- cron: '10 6 * * *'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: postgres
run: mvn clean test -Dprops.file=testconfig/ebean-postgres.properties
@@ -0,0 +1,40 @@
name: SqlServer 2017 latest
on:
workflow_dispatch:
schedule:
- cron: '10 7 * * 2,5'
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
# - name: sqlserver 2019 latest
# run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver.properties
- name: sqlserver 2017 latest
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver17.properties
@@ -0,0 +1,35 @@
name: SqlServer 2019 latest
on: [workflow_dispatch]
jobs:
build:
runs-on: ${{ matrix.os }}
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
java_version: [11]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java_version }}
distribution: 'adopt'
- name: Maven cache
uses: actions/cache@v2
env:
cache-name: maven-cache
with:
path:
~/.m2
key: build-${{ env.cache-name }}
- name: sqlserver 2019 latest
run: mvn clean test -Dprops.file=testconfig/ebean-sqlserver19.properties
+8
View File
@@ -1,5 +1,13 @@
[![Build](https://github.com/ebean-orm/ebean/actions/workflows/build.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/build.yml)
[![Maven Central : ebean](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.ebean/ebean)
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/ebean-orm/ebean/blob/master/LICENSE)
[![Multi-JDK Build](https://github.com/ebean-orm/ebean/actions/workflows/multi-jdk-build.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/multi-jdk-build.yml)
[![JDK 18-ea](https://github.com/ebean-orm/ebean/actions/workflows/jdk-18-ea.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/jdk-18-ea.yml)
[![Postgres](https://github.com/ebean-orm/ebean/actions/workflows/postgres.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/postgres.yml)
[![MySql](https://github.com/ebean-orm/ebean/actions/workflows/mysql.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/mysql.yml)
[![MariaDB](https://github.com/ebean-orm/ebean/actions/workflows/mariadb-10.6.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/mariadb-10.6.yml)
[![SqlServer](https://github.com/ebean-orm/ebean/actions/workflows/sqlserver-2017-latest.yml/badge.svg)](https://github.com/ebean-orm/ebean/actions/workflows/sqlserver-2017-latest.yml)
# Sponsors
<table>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean api</name>
@@ -27,7 +27,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>1.5</version>
<version>1.7</version>
</dependency>
<!--
@@ -378,7 +378,7 @@ public class PlatformConfig {
BINARY(false, true, false),
/**
* Store using DB BINARY(16).
* Store using DB BINARY(16) with optimized packing.
*/
BINARY_OPTIMIZED(false, true, true);
@@ -7,13 +7,10 @@ public class BasicSqlAnsiLimiter implements BasicSqlLimiter {
@Override
public String limit(String dbSql, int firstRow, int maxRows) {
StringBuilder sb = new StringBuilder(50 + dbSql.length());
sb.append(dbSql);
if (firstRow > 0) {
sb.append(" ").append("offset");
sb.append(" ").append(firstRow).append(" rows");
sb.append(" offset ").append(firstRow).append(" rows");
}
if (maxRows > 0) {
sb.append(" fetch next ").append(maxRows).append(" rows only");
@@ -20,6 +20,8 @@ public class DB2Platform extends DatabasePlatform {
public DB2Platform() {
super();
this.platform = Platform.DB2;
// Note: DB2 (at least LUW supports length up to 128)
// TOOD: Check if we need to introduce a new platform (DB2_LUW_11 ?)
this.maxTableNameLength = 18;
this.maxConstraintNameLength = 18;
this.truncateTable = "truncate table %s reuse storage ignore delete triggers immediate";
@@ -1,6 +1,10 @@
package io.ebean.config.dbplatform.mariadb;
import javax.sql.DataSource;
import io.ebean.BackgroundExecutor;
import io.ebean.annotation.Platform;
import io.ebean.config.dbplatform.PlatformIdGenerator;
import io.ebean.config.dbplatform.mysql.BaseMySqlPlatform;
/**
@@ -11,6 +15,14 @@ public class MariaDbPlatform extends BaseMySqlPlatform {
public MariaDbPlatform() {
super();
this.platform = Platform.MARIADB;
this.sequenceBatchMode = false;
this.historySupport = new MariaDbHistorySupport();
this.dbIdentity.setSupportsSequence(true);
}
@Override
public PlatformIdGenerator createSequenceIdGenerator(BackgroundExecutor be, DataSource ds, int stepSize, String seqName) {
return new MariaDbSequence(be, ds, seqName, stepSize);
}
}
@@ -0,0 +1,24 @@
package io.ebean.config.dbplatform.mariadb;
import io.ebean.BackgroundExecutor;
import io.ebean.config.dbplatform.SequenceStepIdGenerator;
import javax.sql.DataSource;
public class MariaDbSequence extends SequenceStepIdGenerator {
private final String nextSql;
/**
* Construct where batchSize is the sequence step size.
*/
public MariaDbSequence(BackgroundExecutor be, DataSource ds, String seqName, int stepSize) {
super(be, ds, seqName, stepSize);
this.nextSql = "select next value for " + seqName;
}
@Override
public String getSql(int batchSize) {
return nextSql;
}
}
@@ -11,6 +11,7 @@ public class Oracle11Platform extends OraclePlatform {
public Oracle11Platform() {
super();
this.platform = Platform.ORACLE11;
this.columnAliasPrefix = "c";
this.sqlLimiter = new OracleRownumSqlLimiter();
this.basicSqlLimiter = new OracleRownumBasicLimiter();
dbIdentity.setIdType(IdType.SEQUENCE);
@@ -0,0 +1,13 @@
package io.ebean.config.dbplatform.oracle;
/**
* Oracle 12 platform using column alias.
*/
public class Oracle12Platform extends OraclePlatform {
public Oracle12Platform() {
super();
//this.platform = Platform.ORACLE12;
this.columnAliasPrefix = "c";
}
}
@@ -22,7 +22,6 @@ public class OraclePlatform extends DatabasePlatform {
public OraclePlatform() {
super();
this.platform = Platform.ORACLE;
this.columnAliasPrefix = "c";
this.supportsDeleteTableAlias = true;
this.maxTableNameLength = 30;
this.maxConstraintNameLength = 30;
@@ -35,11 +34,9 @@ public class OraclePlatform extends DatabasePlatform {
dbIdentity.setSupportsSequence(true);
dbIdentity.setSupportsIdentity(true);
dbIdentity.setSupportsGetGeneratedKeys(true);
this.dbDefaultValue.setFalse("0");
this.dbDefaultValue.setTrue("1");
this.dbDefaultValue.setNow("current_timestamp");
this.treatEmptyStringsAsNull = true;
this.likeClauseRaw = "like ?";
@@ -56,7 +53,6 @@ public class OraclePlatform extends DatabasePlatform {
booleanDbType = Types.INTEGER;
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("number(1)"));
dbTypeMap.put(DbType.INTEGER, new DbPlatformType("number", 10));
dbTypeMap.put(DbType.BIGINT, new DbPlatformType("number", 19));
dbTypeMap.put(DbType.REAL, new DbPlatformType("number", 19, 4));
@@ -65,12 +61,10 @@ public class OraclePlatform extends DatabasePlatform {
dbTypeMap.put(DbType.TINYINT, new DbPlatformType("number", 3));
dbTypeMap.put(DbType.DECIMAL, new DbPlatformType("number", 16, 3));
dbTypeMap.put(DbType.VARCHAR, new DbPlatformType("varchar2", 255));
dbTypeMap.put(DbType.LONGVARBINARY, new DbPlatformType("blob"));
dbTypeMap.put(DbType.LONGVARCHAR, new DbPlatformType("clob"));
dbTypeMap.put(DbType.VARBINARY, new DbPlatformType("raw", 255));
dbTypeMap.put(DbType.BINARY, new DbPlatformType("raw", 255));
dbTypeMap.put(DbType.TIME, new DbPlatformType("timestamp"));
}
@@ -24,6 +24,7 @@ public class SQLitePlatform extends DatabasePlatform {
this.dbDefaultValue.setFalse("0");
this.dbDefaultValue.setTrue("1");
this.dbDefaultValue.setNow("CURRENT_TIMESTAMP");
this.supportsResultSetConcurrencyModeUpdatable = false;
dbTypeMap.put(DbType.BIT, new DbPlatformType("int"));
dbTypeMap.put(DbType.BOOLEAN, new DbPlatformType("int"));
@@ -43,6 +43,12 @@ public interface BeanPersistRequest<T> {
return transaction();
}
/**
* Return true if this request is due to cascading persist.
* False implies this is a "top level" request.
*/
boolean isCascade();
/**
* For an update or delete of a partially populated bean this is the set of
* loaded properties and otherwise returns null.
@@ -1,14 +0,0 @@
package io.ebean.plugin;
import io.ebean.bean.EntityBean;
/**
* Errorhandler to handle load errors and may be recover correct value.
*
* @author Roland Praml, FOCONIS AG
*
*/
@FunctionalInterface
public interface LoadErrorHandler {
void handleLoadError(EntityBean bean, Property prop, String fullName, Exception e);
}
@@ -18,7 +18,7 @@ import java.util.Locale;
* try {
* File f = new File("src/test/resources/test1.csv");
*
* FileReader reader = new FileReader(f);
* FileReader reader = new FileReader(f, encoding);
*
* CsvReader<Customer> csvReader = DB.createCsvReader(Customer.class);
*
@@ -71,6 +71,20 @@ public class AnnotationUtil {
return typeGet(clazz, annotation) != null;
}
/**
* Check if an element is annotated with an annotation of given type searching meta-annotations.
*/
public static boolean metaHas(AnnotatedElement element, Class<?> annotationType) {
return !metaFindAll(element, annotationType).isEmpty();
}
/**
* Find all the annotations of a given type searching meta-annotations.
*/
public static Set<Annotation> metaFindAll(AnnotatedElement element, Class<?> annotationType) {
return metaFindAllFor(element, Collections.singleton(annotationType));
}
/**
* Find all the annotations for the filter searching meta-annotations.
*/
@@ -0,0 +1,48 @@
package io.ebean.util;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
/**
* Utilities for IO. It uses UTF-8 as encoding when reading/writing and uses
* buffered IO for better performance.
*/
public class IOUtils {
/**
* Read from stream as UTF-8.
*/
public static BufferedReader newReader(InputStream is) {
return new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
}
/**
* Read from file as UTF-8.
*/
public static BufferedReader newReader(File file) throws FileNotFoundException {
return newReader(new FileInputStream(file));
}
/**
* Write to stream as UTF-8
*/
public static BufferedWriter newWriter(OutputStream os) {
return new BufferedWriter(new OutputStreamWriter(os, StandardCharsets.UTF_8));
}
/**
* Write to file as UTF-8
*/
public static BufferedWriter newWriter(File file) throws FileNotFoundException {
return newWriter(new FileOutputStream(file));
}
}
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
@@ -14,7 +14,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.13.1</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<name>ebean autotune</name>
@@ -26,7 +26,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
+15 -15
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean bom</name>
@@ -71,88 +71,88 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-xml</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-autotune</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
</dependencies>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
+5 -5
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<artifactId>ebean-core</artifactId>
@@ -15,7 +15,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.13.1</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<dependencies>
@@ -41,19 +41,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
@@ -3,13 +3,13 @@ package io.ebeaninternal.server.core;
import io.ebean.ScriptRunner;
import io.ebean.ddlrunner.DdlRunner;
import io.ebean.ddlrunner.ScriptTransform;
import io.ebean.util.IOUtils;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.util.UrlHelper;
import javax.persistence.PersistenceException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.net.URL;
@@ -66,8 +66,9 @@ final class DScriptRunner implements ScriptRunner {
throw new IllegalArgumentException("resource is null?");
}
try (InputStream inputStream = UrlHelper.openNoCache(resource)) {
return readContent(new InputStreamReader(inputStream));
try (InputStream inputStream = UrlHelper.openNoCache(resource);
Reader reader = IOUtils.newReader(inputStream)) {
return readContent(reader);
} catch (IOException e) {
throw new PersistenceException("Failed to read script content", e);
@@ -13,6 +13,7 @@ import io.ebean.config.dbplatform.mysql.MySql55Platform;
import io.ebean.config.dbplatform.mysql.MySqlPlatform;
import io.ebean.config.dbplatform.nuodb.NuoDbPlatform;
import io.ebean.config.dbplatform.oracle.Oracle11Platform;
import io.ebean.config.dbplatform.oracle.Oracle12Platform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import io.ebean.config.dbplatform.postgres.Postgres9Platform;
import io.ebean.config.dbplatform.postgres.PostgresPlatform;
@@ -25,11 +26,7 @@ import io.ebeaninternal.api.DbOffline;
import javax.persistence.PersistenceException;
import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.*;
/**
* Create a DatabasePlatform from the configuration.
@@ -87,6 +84,9 @@ public class DatabasePlatformFactory {
if (dbName.equals("oracle11") || dbName.equals("oracle10") || dbName.equals("oracle9")) {
return new Oracle11Platform();
}
if (dbName.equals("oracle12")) {
return new Oracle12Platform();
}
if (dbName.equals("oracle")) {
return new OraclePlatform();
}
@@ -173,7 +173,13 @@ public class DatabasePlatformFactory {
}
private DatabasePlatform oracleVersion(int majorVersion) {
return majorVersion < 12 ? new Oracle11Platform() : new OraclePlatform();
if (majorVersion < 12) {
return new Oracle11Platform();
}
if (majorVersion < 13) {
return new Oracle12Platform();
}
return new OraclePlatform();
}
private DatabasePlatform mysqlVersion(int majorVersion, int minorVersion) {
@@ -213,6 +213,11 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
return beanDescriptor.docStoreMode(type, txnMode);
}
@Override
public boolean isCascade() {
return Flags.isRecurse(flags);
}
/**
* Return true if the draftDirty property should be set to true for this request.
*/
@@ -226,7 +226,7 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
*/
@Override
public void addBeanToCollectionWithCreate(EntityBean parentBean, EntityBean detailBean, boolean withCheck) {
BeanCollection<?> bc = (BeanCollection<?>) super.getValue(parentBean);
BeanCollection<?> bc = beanCollection(parentBean);
if (bc == null) {
bc = help.createEmpty(parentBean);
setValue(parentBean, bc);
@@ -234,6 +234,15 @@ public class BeanPropertyAssocMany<T> extends BeanPropertyAssoc<T> implements ST
help.add(bc, detailBean, withCheck);
}
private BeanCollection<?> beanCollection(EntityBean parentBean) {
try {
return (BeanCollection<?>) super.getValue(parentBean);
} catch (ClassCastException e) {
// fetching element collection, ok for now
return null;
}
}
/**
* Return true if this is considered 'empty' from a save perspective.
*/
@@ -10,23 +10,18 @@ public final class DbExpressionHandlerFactory {
* Create and return the appropriate platform specific handing of expressions.
*/
public static DbExpressionHandler from(DatabasePlatform databasePlatform) {
Platform platform = databasePlatform.getPlatform();
Platform platform = databasePlatform.getPlatform().base();
switch (platform) {
case H2:
return new H2DbExpression();
case POSTGRES:
case POSTGRES9:
return new PostgresDbExpression();
case MARIADB:
return new MariaDbExpression();
case MYSQL55:
case MYSQL:
return new MySqlDbExpression();
case ORACLE:
case ORACLE11:
return new OracleDbExpression();
case SQLSERVER16:
case SQLSERVER17:
case SQLSERVER:
return new SqlServerDbExpression();
case HANA:
@@ -333,6 +333,13 @@ public final class DefaultPersister implements Persister {
* Recursively delete the bean. This calls back to the EbeanServer.
*/
private int deleteRecurse(EntityBean detailBean, Transaction t, DeleteMode deleteMode) {
return deleteRequest(createDeleteCascade(detailBean, t, deleteMode.persistType()));
}
/**
* Delete without being a cascade.
*/
private int delete(EntityBean detailBean, Transaction t, DeleteMode deleteMode) {
return deleteRequest(createDeleteRequest(detailBean, t, deleteMode.persistType()));
}
@@ -560,7 +567,7 @@ public final class DefaultPersister implements Persister {
}
}
private void deleteList(List<?> beanList, SpiTransaction t, DeleteMode deleteMode, boolean children) {
private void deleteCascade(List<?> beanList, SpiTransaction t, DeleteMode deleteMode, boolean children) {
if (children) {
t.depth(-1);
t.checkBatchEscalationOnCollection();
@@ -604,7 +611,7 @@ public final class DefaultPersister implements Persister {
for (Object id : ids) {
EntityBean bean = descriptor.createEntityBean();
descriptor.convertSetId(id, bean);
int rowCount = deleteRecurse(bean, transaction, deleteMode);
int rowCount = delete(bean, transaction, deleteMode);
if (rowCount == -1) {
total = -1;
} else if (total != -1) {
@@ -656,7 +663,7 @@ public final class DefaultPersister implements Persister {
t.logSummary("-- DeleteById of " + descriptor.name() + " ids[" + idList + "] requires fetch of foreign key values");
}
List<?> beanList = server.findList(q, t);
deleteList(beanList, t, deleteMode, false);
deleteCascade(beanList, t, deleteMode, false);
return beanList.size();
} else {
@@ -994,6 +1001,8 @@ public final class DefaultPersister implements Persister {
executeSqlUpdate(sqlDelete, t);
} else {
// TODO: Review first checking if many property is loaded and using the loaded beans
// ... and only using findIdsByParentId() when the many property isn't loaded
// Delete recurse using the Id values of the children
Object parentId = desc.getId(parentBean);
List<Object> idsByParentId = many.findIdsByParentId(parentId, null, t, excludeDetailIds, deleteMode.isHard());
@@ -1017,7 +1026,7 @@ public final class DefaultPersister implements Persister {
for (Object id : childIds) {
refList.add(targetDesc.createReference(id, null));
}
deleteList(refList, t, deleteMode, true);
deleteCascade(refList, t, deleteMode, true);
} else {
// perform delete by statement if possible
delete(targetDesc, null, childIds, t, deleteMode);
@@ -1157,6 +1166,10 @@ public final class DefaultPersister implements Persister {
return createDeleteRequest(bean, t, type, Flags.ZERO);
}
private <T> PersistRequestBean<T> createDeleteCascade(EntityBean bean, Transaction t, Type type) {
return createDeleteRequest(bean, t, type, Flags.RECURSE);
}
@SuppressWarnings({"unchecked"})
private <T> PersistRequestBean<T> createDeleteRequest(Object bean, Transaction t, PersistRequest.Type type, int flags) {
BeanManager<T> mgr = beanManager(bean.getClass());
@@ -1167,7 +1180,7 @@ public final class DefaultPersister implements Persister {
type = Type.DELETE_SOFT;
}
PersistRequestBean<T> request = new PersistRequestBean<>(server, (T)bean, null, mgr, (SpiTransaction) t, persistExecute, type, flags);
PersistRequestBean<T> request = new PersistRequestBean<>(server, (T) bean, null, mgr, (SpiTransaction) t, persistExecute, type, flags);
request.initForSoftDelete();
return request;
}
@@ -1186,7 +1199,7 @@ public final class DefaultPersister implements Persister {
*/
@SuppressWarnings("unchecked")
private <T> BeanManager<T> beanManager(Class<?> cls) {
BeanManager<T> mgr = (BeanManager<T>)beanDescriptorManager.beanManager(cls);
BeanManager<T> mgr = (BeanManager<T>) beanDescriptorManager.beanManager(cls);
if (mgr == null) {
throw new PersistenceException(errNotRegistered(cls));
}
@@ -13,11 +13,8 @@ import io.ebeaninternal.server.persist.dmlbind.BindableList;
import java.sql.SQLException;
import static io.ebean.annotation.Platform.MARIADB;
import static io.ebean.annotation.Platform.MYSQL;
/**
* Meta data for insert handler. The meta data is for a particular bean type. It
* Metadata for insert handler. The metadata is for a particular bean type. It
* is considered immutable and is thread safe.
*/
final class InsertMeta {
@@ -153,31 +150,25 @@ final class InsertMeta {
private String genSql(boolean nullId, String table, boolean draftTable) {
GenerateDmlRequest request = new GenerateDmlRequest();
request.setInsertSetMode();
request.append("insert into ").append(table);
if (nullId && noColumnsForInsert(draftTable)) {
return request.append(defaultValues()).toString();
}
request.append(" (");
if (!nullId) {
id.dmlAppend(request);
}
if (shadowFKey != null) {
shadowFKey.dmlAppend(request);
}
if (discriminator != null) {
discriminator.dmlAppend(request);
}
if (draftTable) {
all.dmlAppend(request);
} else {
allExcludeDraftOnly.dmlAppend(request);
}
request.append(") values (");
request.append(request.getInsertBindBuffer());
request.append(")");
@@ -185,7 +176,14 @@ final class InsertMeta {
}
private String defaultValues() {
return platform.base() == MYSQL || platform.base() == MARIADB ? " values (default)" : " default values";
switch (platform.base()) {
case MYSQL:
case MARIADB:
case ORACLE:
return " values (default)";
default:
return " default values";
}
}
/**
@@ -736,6 +736,8 @@ final class CQueryBuilder {
return " order by count(*) desc, r1.attribute_";
case COUNT_DESC_ATTR_DESC:
return " order by count(*) desc, r1.attribute_ desc";
case NO_ORDERING:
return "";
default:
throw new IllegalArgumentException("Illegal enum: " + orderBy);
}
@@ -4,11 +4,13 @@ import io.ebean.ProfileLocation;
import io.ebean.config.ProfilingConfig;
import io.ebean.plugin.Plugin;
import io.ebean.plugin.SpiServer;
import io.ebean.util.IOUtils;
import io.ebeaninternal.api.CoreLog;
import io.ebeaninternal.api.SpiProfileHandler;
import org.slf4j.Logger;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
@@ -123,7 +125,7 @@ public final class DefaultProfileHandler implements SpiProfileHandler, Plugin {
try {
String now = DTF.format(LocalDateTime.now());
File file = new File(dir, "txprofile-" + now + ".tprofile");
out = new BufferedWriter(new FileWriter(file));
out = IOUtils.newWriter(file);
} catch (IOException e) {
log.error("Not expected", e);
}
@@ -193,7 +193,7 @@ public final class DefaultTypeManager implements TypeManager {
List<? extends ScalarType<?>> types = plugin.createTypes(config, objectMapper);
for (ScalarType<?> type : types) {
log.debug("adding ScalarType {}", type.getClass());
addCustomType(type);
add(type);
}
}
}
@@ -211,25 +211,6 @@ public final class DefaultTypeManager implements TypeManager {
logAdd(scalarType);
}
/**
* Register the ScalarType for an enum. This is special in the sense that an Enum
* can have many classes if it uses method overrides and we need to register all
* the variations/classes for the enum.
*/
@SuppressWarnings({"rawtypes", "unchecked"})
@Override
public void addEnumType(ScalarType<?> scalarType, Class<? extends Enum> enumClass) {
Set<Class<?>> mappedClasses = new HashSet<>();
mappedClasses.add(enumClass);
for (Object value : EnumSet.allOf(enumClass).toArray()) {
mappedClasses.add(value.getClass());
}
for (Class<?> cls : mappedClasses) {
typeMap.put(cls, scalarType);
}
logAdd(scalarType);
}
private void logAdd(ScalarType<?> scalarType) {
if (log.isTraceEnabled()) {
String msg = "ScalarType register [" + scalarType.getClass().getName() + "]";
@@ -275,16 +256,43 @@ public final class DefaultTypeManager implements TypeManager {
"ScalarType of Joda LocalTime not defined. You need to set DatabaseConfig.jodaLocalTimeMode to"
+ " either 'normal' or 'utc'. UTC is the old mode using UTC timezone but local time zone is now preferred as 'normal' mode.");
}
found = checkInterfaceTypes(type);
found = checkInheritedTypes(type);
}
return found;
return found != ScalarTypeNotFound.INSTANCE ? found : null; // Do not return ScalarTypeNotFound, otherwise checks will fail
}
private ScalarType<?> checkInterfaceTypes(Class<?> type) {
if (java.nio.file.Path.class.isAssignableFrom(type)) {
return typeMap.get(java.nio.file.Path.class);
/**
* Checks the typeMap for inherited types.
*
* If e.g. <code>type</code> is a <code>GregorianCalendar</code>, then this method
* will check the class hierarchy and will probably return a
* <code>ScalarTypeCalendar</code> To speed up a second lookup, it will write
* back the found scalarType to typeMap.
*
* @param type the for which to search for a <code>ScalarType</code>
* @return either a valid <code>ScalarType</code> if one could be found or {@link ScalarTypeNotFound#INSTANCE} if not
*/
private ScalarType<?> checkInheritedTypes(Class<?> type) {
// first step loop through inheritance chain
Class<?> parent = type;
while (parent != null && parent != Object.class) {
ScalarType<?> found = typeMap.get(parent);
if (found != null && found != ScalarTypeNotFound.INSTANCE) {
typeMap.put(type, found); // store type for next lookup
return found;
}
// second step - loop through interfaces of this type
for (Class<?> iface: parent.getInterfaces()) {
found = checkInheritedTypes(iface);
if (found != null && found != ScalarTypeNotFound.INSTANCE) {
typeMap.put(type, found); // store type for next lookup
return found;
}
}
parent = parent.getSuperclass();
}
return null;
typeMap.put(type, ScalarTypeNotFound.INSTANCE);
return ScalarTypeNotFound.INSTANCE; // no success
}
@Override
@@ -337,11 +345,10 @@ public final class DefaultTypeManager implements TypeManager {
Type genericType = prop.getGenericType();
boolean hasJacksonAnnotations = objectMapperPresent && checkJacksonAnnotations(prop);
boolean keepSource = prop.getMutationDetection() == MutationDetection.SOURCE;
if (type.equals(List.class)) {
DocPropertyType docType = getDocType(genericType);
if (!hasJacksonAnnotations && isValueTypeSimple(genericType)) {
return ScalarTypeJsonList.typeFor(postgres, dbType, docType, prop.isNullable(), keepSource);
return ScalarTypeJsonList.typeFor(postgres, dbType, docType, prop.isNullable(), jsonManager.keepSource(prop));
} else {
return createJsonObjectMapperType(prop, dbType, docType);
}
@@ -349,14 +356,14 @@ public final class DefaultTypeManager implements TypeManager {
if (type.equals(Set.class)) {
DocPropertyType docType = getDocType(genericType);
if (!hasJacksonAnnotations && isValueTypeSimple(genericType)) {
return ScalarTypeJsonSet.typeFor(postgres, dbType, docType, prop.isNullable(), keepSource);
return ScalarTypeJsonSet.typeFor(postgres, dbType, docType, prop.isNullable(), jsonManager.keepSource(prop));
} else {
return createJsonObjectMapperType(prop, dbType, docType);
}
}
if (type.equals(Map.class)) {
if (!hasJacksonAnnotations && isMapValueTypeObject(genericType)) {
return ScalarTypeJsonMap.typeFor(postgres, dbType, keepSource);
return ScalarTypeJsonMap.typeFor(postgres, dbType, jsonManager.keepSource(prop));
} else {
return createJsonObjectMapperType(prop, dbType, DocPropertyType.OBJECT);
}
@@ -390,7 +397,7 @@ public final class DefaultTypeManager implements TypeManager {
private DocPropertyType getDocType(Type genericType) {
if (genericType instanceof Class<?>) {
ScalarType<?> found = typeMap.get(genericType);
ScalarType<?> found = getScalarType((Class<?>)genericType);
if (found != null) {
return found.getDocType();
}
@@ -448,7 +455,7 @@ public final class DefaultTypeManager implements TypeManager {
return scalarType;
}
scalarType = typeMap.get(type);
scalarType = getScalarType(type);
if (scalarType != null) {
if (jdbcType == 0 || scalarType.getJdbcType() == jdbcType) {
// matching type
@@ -566,7 +573,7 @@ public final class DefaultTypeManager implements TypeManager {
// use JPA normal Enum type (without mapping)
scalarEnum = createEnumScalarTypePerSpec(enumType, type);
}
addEnumType(scalarEnum, enumType);
add(scalarEnum);
return scalarEnum;
}
@@ -656,16 +663,13 @@ public final class DefaultTypeManager implements TypeManager {
scalarType = cls.getDeclaredConstructor().newInstance();
}
}
addCustomType(scalarType);
add(scalarType);
} catch (Exception e) {
log.error("Error loading ScalarType [" + cls.getName() + "]", e);
}
}
}
private void addCustomType(ScalarType<?> scalarType) {
add(scalarType);
}
private Object initObjectMapper(DatabaseConfig config) {
Object objectMapper = config.getObjectMapper();
@@ -8,6 +8,7 @@ import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.text.TextException;
import io.ebean.text.json.EJson;
import io.ebean.util.IOUtils;
import java.io.*;
import java.nio.charset.StandardCharsets;
@@ -75,14 +76,14 @@ abstract class ScalarTypeJsonMap extends ScalarTypeBase<Map> {
try {
if (keepSource) {
StringWriter jsonBuffer = new StringWriter();
try (InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
try (Reader streamReader = IOUtils.newReader(is)) {
transferTo(streamReader, jsonBuffer);
}
String rawJson = jsonBuffer.toString();
reader.pushJson(rawJson);
return parse(rawJson);
} else {
try (InputStreamReader streamReader = new InputStreamReader(is, StandardCharsets.UTF_8)) {
try (Reader streamReader = IOUtils.newReader(is)) {
return parse(streamReader);
}
}
@@ -8,12 +8,12 @@ import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.text.TextException;
import io.ebean.util.IOUtils;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.sql.SQLException;
@@ -68,7 +68,7 @@ abstract class ScalarTypeJsonNode extends ScalarTypeBase<JsonNode> {
if (is == null) {
return null;
}
try (InputStreamReader reader = new InputStreamReader(is)) {
try (Reader reader = IOUtils.newReader(is)) {
return parse(reader);
} catch (IOException e) {
throw new SQLException("Error reading Blob stream from DB", e);
@@ -0,0 +1,140 @@
package io.ebeaninternal.server.type;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import java.sql.SQLException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.core.type.DataBinder;
import io.ebean.core.type.DataReader;
import io.ebean.core.type.DocPropertyType;
import io.ebean.core.type.ScalarType;
/**
* Class is required as "null" key in ConcurrentHashMap.
* @author Roland Praml, FOCONIS AG
*
*/
class ScalarTypeNotFound implements ScalarType<Void> {
public static final ScalarTypeNotFound INSTANCE = new ScalarTypeNotFound();
private ScalarTypeNotFound() { }
@Override
public boolean isBinaryType() {
throw new UnsupportedOperationException();
}
@Override
public boolean isMutable() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDirty(Object value) {
throw new UnsupportedOperationException();
}
@Override
public int getLength() {
throw new UnsupportedOperationException();
}
@Override
public boolean isJdbcNative() {
throw new UnsupportedOperationException();
}
@Override
public int getJdbcType() {
throw new UnsupportedOperationException();
}
@Override
public Class<Void> getType() {
throw new UnsupportedOperationException();
}
@Override
public Void read(DataReader reader) throws SQLException {
throw new UnsupportedOperationException();
}
@Override
public void loadIgnore(DataReader reader) {
throw new UnsupportedOperationException();
}
@Override
public void bind(DataBinder binder, Void value) throws SQLException {
throw new UnsupportedOperationException();
}
@Override
public Object toJdbcType(Object value) {
throw new UnsupportedOperationException();
}
@Override
public Void toBeanType(Object value) {
throw new UnsupportedOperationException();
}
@Override
public String formatValue(Void value) {
throw new UnsupportedOperationException();
}
@Override
public String format(Object value) {
throw new UnsupportedOperationException();
}
@Override
public Void parse(String value) {
throw new UnsupportedOperationException();
}
@Override
public DocPropertyType getDocType() {
throw new UnsupportedOperationException();
}
@Override
public boolean isDateTimeCapable() {
throw new UnsupportedOperationException();
}
@Override
public long asVersion(Void value) {
throw new UnsupportedOperationException();
}
@Override
public Void convertFromMillis(long dateTime) {
throw new UnsupportedOperationException();
}
@Override
public Void readData(DataInput dataInput) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void writeData(DataOutput dataOutput, Void v) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public Void jsonRead(JsonParser parser) throws IOException {
throw new UnsupportedOperationException();
}
@Override
public void jsonWrite(JsonGenerator writer, Void value) throws IOException {
throw new UnsupportedOperationException();
}
}
@@ -32,7 +32,7 @@ public final class SimpleAesEncryptor implements Encryptor {
}
private IvParameterSpec getIvParameterSpec(String initialVector) {
return new IvParameterSpec(initialVector.getBytes());
return new IvParameterSpec(initialVector.getBytes(StandardCharsets.UTF_8));
}
@Override
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import io.ebean.ModifyAwareType;
import io.ebean.annotation.MutationDetection;
import io.ebean.config.dbplatform.DbPlatformType;
import io.ebeaninternal.server.deploy.meta.DeployBeanProperty;
final class TypeJsonManager {
@@ -25,6 +26,17 @@ final class TypeJsonManager {
return objectMapper;
}
boolean keepSource(DeployBeanProperty prop) {
if (prop.getMutationDetection() == MutationDetection.SOURCE) {
return true;
} else if (prop.getMutationDetection() == MutationDetection.DEFAULT) {
prop.setMutationDetection(mutationDetection);
return mutationDetection == MutationDetection.SOURCE;
} else {
return false;
}
}
String postgresType(int dbType) {
if (postgres) {
switch (dbType) {
@@ -17,12 +17,6 @@ public interface TypeManager {
*/
void add(ScalarType<?> scalarType);
/**
* Register a ScalarType for an Enum with can have multiple classes.
*/
@SuppressWarnings("rawtypes")
void addEnumType(ScalarType<?> type, Class<? extends Enum> myEnumClass);
/**
* Return the scalar type for the given logical type.
*/
+4 -4
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean ddl generation</name>
@@ -22,20 +22,20 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
<version>12.13.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
@@ -5,6 +5,7 @@ import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.ddlrunner.DdlRunner;
import io.ebean.ddlrunner.ScriptTransform;
import io.ebean.util.IOUtils;
import io.ebean.util.JdbcClose;
import io.ebeaninternal.api.SpiDdlGenerator;
import io.ebeaninternal.api.SpiEbeanServer;
@@ -17,13 +18,11 @@ import org.slf4j.LoggerFactory;
import javax.persistence.PersistenceException;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.io.Writer;
import java.sql.Connection;
import java.sql.SQLException;
@@ -268,7 +267,7 @@ public class DdlGenerator implements SpiDdlGenerator {
if (is == null) {
log.warn("sql script {} was not found as a resource", sqlScript);
} else {
String content = readContent(new InputStreamReader(is));
String content = readContent(IOUtils.newReader(is)); // 'is' is closed
runScript(connection, false, content, sqlScript);
}
}
@@ -337,7 +336,7 @@ public class DdlGenerator implements SpiDdlGenerator {
protected void writeFile(String fileName, String fileContent) throws IOException {
File f = new File(baseDir, fileName);
try (FileWriter fw = new FileWriter(f)) {
try (Writer fw = IOUtils.newWriter(f)) {
fw.write(fileContent);
fw.flush();
}
@@ -348,7 +347,9 @@ public class DdlGenerator implements SpiDdlGenerator {
if (!f.exists()) {
return null;
}
return readContent(new FileReader(f));
try (Reader reader = IOUtils.newReader(f)) {
return readContent(reader);
}
}
protected String readContent(Reader reader) throws IOException {
@@ -1,8 +1,22 @@
package io.ebeaninternal.dbmigration;
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
import java.io.File;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.StringJoiner;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import io.ebean.DB;
import io.ebean.Database;
import io.ebean.annotation.Platform;
import io.ebean.config.ClassLoadConfig;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.DbConstraintNaming;
import io.ebean.config.PlatformConfig;
@@ -27,6 +41,8 @@ import io.ebean.config.dbplatform.sqlite.SQLitePlatform;
import io.ebean.config.dbplatform.sqlserver.SqlServer16Platform;
import io.ebean.config.dbplatform.sqlserver.SqlServer17Platform;
import io.ebean.dbmigration.DbMigration;
import io.ebean.util.IOUtils;
import io.ebean.util.StringHelper;
import io.ebeaninternal.api.DbOffline;
import io.ebeaninternal.api.SpiEbeanServer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlOptions;
@@ -42,17 +58,6 @@ import io.ebeaninternal.dbmigration.model.PlatformDdlWriter;
import io.ebeaninternal.extraddl.model.DdlScript;
import io.ebeaninternal.extraddl.model.ExtraDdl;
import io.ebeaninternal.extraddl.model.ExtraDdlXmlReader;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import static io.ebeaninternal.api.PlatformMatch.matchPlatform;
/**
* Generates DB Migration xml and sql scripts.
@@ -417,7 +422,7 @@ public class DefaultDbMigration implements DbMigration {
String fullName = repeatableMigrationName(script.isInit(), script.getName());
logger.debug("writing repeatable script {}", fullName);
File file = new File(migrationDir, fullName);
try (FileWriter writer = new FileWriter(file)) {
try (Writer writer = IOUtils.newWriter(file)) {
writer.write(script.getValue());
writer.flush();
}
@@ -2,10 +2,11 @@ package io.ebeaninternal.dbmigration;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.migration.MigrationVersion;
import io.ebean.util.IOUtils;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -50,17 +51,17 @@ class IndexMigration {
private void generateIndex() throws IOException {
Collections.sort(all);
FileWriter writer = new FileWriter(indexFile);
for (Entry entry : all) {
writeChecksumPadded(writer, entry.checksum);
writer.write(entry.fileName);
try (Writer writer = IOUtils.newWriter(indexFile)) {
for (Entry entry : all) {
writeChecksumPadded(writer, entry.checksum);
writer.write(entry.fileName);
writer.write(eol);
}
writer.write(eol);
}
writer.write(eol);
writer.close();
}
private void writeChecksumPadded(FileWriter writer, int checksum) throws IOException {
private void writeChecksumPadded(Writer writer, int checksum) throws IOException {
final String asStr = String.valueOf(checksum);
writer.write(asStr);
writer.write(',');
@@ -4,6 +4,8 @@ import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.zip.CRC32;
import io.ebean.util.IOUtils;
/**
* Calculates the checksum for the given file content.
*/
@@ -13,9 +15,8 @@ class MChecksum {
* Returns the checksum of the file. Agnostic of encoding and new line character.
*/
static int calculate(File file) {
try {
try (BufferedReader bufferedReader = IOUtils.newReader(file)) {
final CRC32 crc32 = new CRC32();
BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
String line;
while ((line = bufferedReader.readLine()) != null) {
final byte[] lineBytes = line.getBytes(StandardCharsets.UTF_8);
@@ -14,6 +14,7 @@ class ClickHouseDbArray {
mapping.put("varchar[]", "Array(String)");
mapping.put("integer[]", "Array(UInt32)");
mapping.put("bigint[]", "Array(UInt64)");
mapping.put("float[]", "Array(Float32)");
}
/**
@@ -21,6 +22,10 @@ class ClickHouseDbArray {
*/
static String logicalToNative(String logicalArrayType) {
int colonPos = logicalArrayType.indexOf(':');
int bracketPos = logicalArrayType.indexOf('(');
if (bracketPos > -1 && (bracketPos < colonPos || colonPos == -1)) {
colonPos = bracketPos;
}
if (colonPos > -1) {
logicalArrayType = logicalArrayType.substring(0, colonPos);
}
@@ -1,14 +1,15 @@
package io.ebeaninternal.dbmigration.migrationreader;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.migration.Migration;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
/**
* Simple writer for output of the Migration/ChangeSet as an XML document.
@@ -26,7 +27,7 @@ public class MigrationXmlWriter {
*/
public void write(Migration migration, File file) {
try (FileWriter writer = new FileWriter(file)) {
try (Writer writer = IOUtils.newWriter(file)) {
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n");
if (comment != null) {
@@ -2,6 +2,7 @@ package io.ebeaninternal.dbmigration.model;
import io.ebean.config.DatabaseConfig;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlBuffer;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlHandler;
import io.ebeaninternal.dbmigration.ddlgeneration.DdlWrite;
@@ -14,7 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Writer;
import java.util.List;
@@ -70,16 +70,16 @@ public class PlatformDdlWriter {
*/
protected void writePlatformDdl(DdlWrite write, File resourcePath, String fullVersion) throws IOException {
if (!write.isApplyEmpty()) {
try (FileWriter applyWriter = createWriter(resourcePath, fullVersion, ".sql")) {
try (Writer applyWriter = createWriter(resourcePath, fullVersion, ".sql")) {
writeApplyDdl(applyWriter, write);
applyWriter.flush();
}
}
}
protected FileWriter createWriter(File path, String fullVersion, String suffix) throws IOException {
protected Writer createWriter(File path, String fullVersion, String suffix) throws IOException {
File applyFile = new File(path, fullVersion + suffix);
return new FileWriter(applyFile);
return IOUtils.newWriter(applyFile);
}
/**
@@ -7,7 +7,7 @@ import java.io.File;
import static org.assertj.core.api.Assertions.assertThat;
public class MChecksumTest {
@Test
public void calculate() {
File file = new File("src/test/resources/dbmigration/index/1.0__hello.sql");
@@ -15,4 +15,12 @@ public class MChecksumTest {
assertThat(MChecksum.calculate(file)).isEqualTo(907060870);
}
@Test
public void calculateWithSpecialChars() {
File file = new File("src/test/resources/dbmigration/index-special-chars/1.0__hello.sql");
assertThat(file).exists();
assertThat(MChecksum.calculate(file)).isEqualTo(1859426839);
}
}
@@ -1,5 +1,6 @@
package io.ebeaninternal.dbmigration.ddlgeneration;
import io.ebean.util.IOUtils;
import io.ebeaninternal.dbmigration.migration.AddColumn;
import io.ebeaninternal.dbmigration.migration.ChangeSet;
import io.ebeaninternal.dbmigration.migration.CreateTable;
@@ -9,8 +10,8 @@ import io.ebeaninternal.dbmigration.migrationreader.MigrationXmlReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.Reader;
import java.util.List;
/**
@@ -89,8 +90,7 @@ public class Helper {
public static String asText(InputStream in) throws IOException {
try {
InputStreamReader reader = new InputStreamReader(in);
try (Reader reader = IOUtils.newReader(in)) {
LineNumberReader lineNumberReader = new LineNumberReader(reader);
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean external mapping api</name>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<!-- <parent>-->
<!-- <groupId>org.avaje</groupId>-->
@@ -14,7 +14,7 @@
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>ebean-parent-12.13.1</tag>
<tag>ebean-parent-12.14.1</tag>
</scm>
<name>ebean external mapping xml</name>
@@ -33,7 +33,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-externalmapping-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
@@ -59,14 +59,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
+104
View File
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.14.1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ebean-kotlin</artifactId>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<ebean-maven-plugin.version>12.13.0</ebean-maven-plugin.version>
<kotlin.version>1.6.0</kotlin.version>
</properties>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.14.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.avaje</groupId>
<artifactId>junit</artifactId>
<version>1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.14.1-SNAPSHOT</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.repaint.maven</groupId>
<artifactId>tiles-maven-plugin</artifactId>
<version>2.24</version>
<extensions>true</extensions>
<configuration>
<tiles>
<tile>io.ebean.tile:enhancement:12.13.1</tile>
</tiles>
</configuration>
</plugin>
</plugins>
</build>
</project>
@@ -0,0 +1,18 @@
package org.example.domain
import io.ebean.Model
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Version
@Entity
class FooEntity(name: String) : Model() {
@Id
var id: Long = 0
var name: String = name
@Version
var version: Long = 0
}
@@ -0,0 +1,21 @@
package org.example.domain
import io.ebean.DB
import org.assertj.core.api.Assertions.assertThat
import org.junit.jupiter.api.Test
class FooEntityTest {
@Test
fun iud() {
val foo = FooEntity("hello")
foo.save()
val found = DB.find(FooEntity::class.java, foo.id)
assertThat(found).isNotNull
found?.delete()
}
}
@@ -0,0 +1,4 @@
ebean:
test:
platform: h2
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean postgis</name>
@@ -23,7 +23,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
@@ -74,7 +74,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean querybean</name>
@@ -17,7 +17,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
@@ -56,21 +56,21 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
+7 -7
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<artifactId>ebean-redis</artifactId>
@@ -16,41 +16,41 @@
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.6.3</version>
<version>3.8.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>test</scope>
</dependency>
+38 -22
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>12.13.1</version>
<version>12.14.1</version>
</parent>
<name>ebean test</name>
@@ -29,14 +29,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>12.13.1</version>
<version>12.14.1</version>
</dependency>
<dependency>
@@ -56,7 +56,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test-docker</artifactId>
<version>4.2</version>
<version>4.4</version>
</dependency>
<dependency>
@@ -91,7 +91,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-migration</artifactId>
<version>12.12.1</version>
<version>12.13.0</version>
<scope>test</scope>
</dependency>
@@ -187,15 +187,46 @@
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc10</artifactId>
<!-- Note: Using ojdbc10 here will affect loading other drivers on jdk8,
because the driverManager will stop on first load error and stops loading
other drivers -->
<artifactId>ojdbc8</artifactId>
<version>19.12.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.nuodb.jdbc</groupId>
<artifactId>nuodb-jdbc</artifactId>
<version>22.0.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ru.yandex.clickhouse</groupId>
<artifactId>clickhouse-jdbc</artifactId>
<version>0.3.1-patch</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
<version>1.2.9</version>
<scope>test</scope>
</dependency>
@@ -208,21 +239,6 @@
</dependencies>
<profiles>
<profile>
<id>db2</id>
<dependencies>
<!-- https://mvnrepository.com/artifact/com.ibm.db2/jcc -->
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>11.5.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
@@ -11,7 +11,7 @@ class ClickHouseSetup implements PlatformSetup {
config.setDefaultPort(8123);
config.setUsername("default");
config.setPassword("");
config.setUrl("jdbc:clickhouse://localhost:${port}/${databaseName}");
config.setUrl("jdbc:clickhouse://${host}:${port}/${databaseName}");
config.setDriver("ru.yandex.clickhouse.ClickHouseDriver");
config.datasourceDefaults();
@@ -11,7 +11,7 @@ class CockroachSetup implements PlatformSetup {
config.setDefaultPort(26257);
config.setUsername("root");
config.setPassword("");
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}?sslmode=disable");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}?sslmode=disable");
config.setDriver("org.postgresql.Driver");
config.datasourceDefaults();
@@ -4,8 +4,8 @@ import io.ebean.config.DatabaseConfig;
import io.ebean.datasource.DataSourceConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
import java.util.Properties;
/**
@@ -26,11 +26,9 @@ class Config {
private final String db;
private final String platform;
private String dockerPlatform;
private String databaseName;
private final Properties properties;
private int port;
private String url;
@@ -38,12 +36,10 @@ class Config {
private String schema;
private String username;
private String password;
private final DatabaseConfig config;
private boolean containerDropCreate;
private final Properties dockerProperties = new Properties();
private final DockerHost dockerHost = new DockerHost();
Config(String db, String platform, String databaseName, DatabaseConfig config) {
this.db = db;
@@ -231,11 +227,17 @@ class Config {
void setUrl(String urlPattern) {
String val = getPlatformKey("url", urlPattern);
val = val.replace("${host}", host());
val = val.replace("${port}", String.valueOf(port));
val = val.replace("${databaseName}", databaseName);
this.url = val;
}
String host() {
String explicitDockerHost = getKey("dockerHost", null);
return getKey("host", dockerHost.dockerHost(explicitDockerHost));
}
/**
* Append to the connection URL.
*/
@@ -322,7 +324,6 @@ class Config {
void setDockerVersion(String version) {
String val = getPlatformKey("version", version);
dockerProperties.setProperty(dockerKey("version"), val);
if (containerDropCreate) {
dockerProperties.setProperty(dockerKey("startMode"), "dropCreate");
}
@@ -369,7 +370,10 @@ class Config {
}
private void initDockerProperties() {
if (dockerHost.runningInDocker()) {
// tell ebean-docker-test we are not using localhost (for jdbc DB setup commands)
dockerProperties.setProperty(dockerKey("host"), dockerHost.dockerHost());
}
dockerProperties.setProperty(dockerKey("port"), String.valueOf(port));
dockerProperties.setProperty(dockerKey("dbName"), databaseName);
if (schema != null) {
@@ -0,0 +1,41 @@
package io.ebean.test.config.platform;
import java.util.Properties;
class Db2Setup implements PlatformSetup {
@Override
public Properties setup(Config config) {
config.ddlMode("dropCreate");
config.setDefaultPort(50000);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:db2://${host}:${port}/${databaseName}");
config.setDriver("com.ibm.db2.jcc.DB2Driver");
config.datasourceDefaults();
return dockerProperties(config);
}
private Properties dockerProperties(Config dbConfig) {
if (!dbConfig.isUseDocker()) {
return new Properties();
}
dbConfig.setDockerVersion("11.5.6.0a");
return dbConfig.getDockerProperties();
}
@Override
public void setupExtraDbDataSource(Config config) {
// not supported yet
}
@Override
public boolean isLocal() {
return false;
}
}
@@ -0,0 +1,55 @@
package io.ebean.test.config.platform;
import java.io.File;
import java.util.Locale;
/**
* Helper to detect if running inside docker and determine host name for that case.
*/
class DockerHost {
private final boolean runningInDocker;
private String dockerHost;
DockerHost() {
runningInDocker = initInDocker();
}
boolean runningInDocker() {
return runningInDocker;
}
String dockerHost() {
return dockerHost;
}
String dockerHost(String explicitHost) {
if (!runningInDocker) {
return "localhost";
}
dockerHost = explicitHost != null ? explicitHost : defaultDockerHost();
return dockerHost;
}
/**
* Return true if running inside a docker container (we are using docker in docker).
*/
boolean initInDocker() {
return new File("/.dockerenv").exists();
}
/**
* Return the default host name to use when running in docker.
* <p>
* Can instead be explicitly specified via <code>ebean.test.dockerHost</code>.
*/
String defaultDockerHost() {
String os = System.getProperty("os.name", "generic").toLowerCase(Locale.ENGLISH);
if (os.contains("mac") || os.contains("darwin") || os.contains("win")) {
return "host.docker.internal";
} else {
return "172.17.0.1";
}
}
}
@@ -20,7 +20,7 @@ class HanaSetup implements PlatformSetup {
config.setUsername("SYSTEM");
config.setPassword("HXEHana1");
config.setDatabaseName("HXE");
config.setUrl("jdbc:sap://localhost:${port}/?databaseName=${databaseName}");
config.setUrl("jdbc:sap://${host}:${port}/?databaseName=${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
config.urlAppend("&currentSchema=" + schema);
@@ -13,7 +13,7 @@ class MariaDBSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:mariadb://localhost:${port}/${databaseName}?useLegacyDatetimeCode=false");
config.setUrl("jdbc:mariadb://${host}:${port}/${databaseName}?useLegacyDatetimeCode=false");
config.datasourceDefaults();
return dockerProperties(config);
@@ -13,7 +13,7 @@ class MySqlSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:mysql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:mysql://${host}:${port}/${databaseName}");
config.setDriver(defaultDriver());
config.datasourceDefaults();
@@ -34,6 +34,7 @@ public class PlatformAutoConfig {
KNOWN_PLATFORMS.put("clickhouse", new ClickHouseSetup());
KNOWN_PLATFORMS.put("cockroach", new CockroachSetup());
KNOWN_PLATFORMS.put("hana", new HanaSetup());
KNOWN_PLATFORMS.put("db2", new Db2Setup());
}
private final DatabaseConfig config;
@@ -20,7 +20,7 @@ class PostgisSetup implements PlatformSetup {
config.setUsernameDefault();
config.setPasswordDefault();
config.setDriver("org.postgis.DriverWrapperLW");
config.setUrl("jdbc:postgresql_lwgis://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql_lwgis://${host}:${port}/${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
@@ -13,7 +13,7 @@ class PostgresSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setUsernameDefault();
config.setPasswordDefault();
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}");
String schema = config.getSchema();
if (schema != null && !schema.equals(config.getUsername())) {
@@ -44,7 +44,7 @@ class PostgresSetup implements PlatformSetup {
config.setDefaultPort(defaultPort);
config.setExtraUsernameDefault();
config.setExtraDbPasswordDefault();
config.setUrl("jdbc:postgresql://localhost:${port}/${databaseName}");
config.setUrl("jdbc:postgresql://${host}:${port}/${databaseName}");
config.setDriver("org.postgresql.Driver");
config.extraDatasourceDefaults();
}
@@ -8,10 +8,14 @@ import java.util.Properties;
class RedisSetup {
static void run(Properties properties) {
String version = properties.getProperty("ebean.test.redis");
version = properties.getProperty("ebean.test.redis.version", version);
if (version != null) {
DockerHost dockerHost = new DockerHost();
if (dockerHost.runningInDocker()) {
String host = dockerHost.dockerHost(properties.getProperty("ebean.test.dockerHost"));
properties.setProperty("redis.host", host);
}
RedisConfig redisConfig = new RedisConfig(version, properties);
RedisContainer container = new RedisContainer(redisConfig);
container.start();
@@ -13,7 +13,7 @@ class SqlServerSetup implements PlatformSetup {
config.setDefaultPort(1433);
config.setUsernameDefault();
config.setPassword("SqlS3rv#r");
config.setUrl("jdbc:sqlserver://localhost:${port};databaseName=${databaseName}");
config.setUrl("jdbc:sqlserver://${host}:${port};databaseName=${databaseName};sendTimeAsDateTime=false");
config.setDriver("com.microsoft.sqlserver.jdbc.SQLServerDriver");
config.datasourceDefaults();
@@ -27,16 +27,17 @@ public class DatabaseConfigTest {
@Test
public void evalPropertiesInput() {
String home = System.getenv("HOME");
String home = System.getProperty("user.home");
String fileSeparator = System.getProperty("file.separator");
Properties props = new Properties();
props.setProperty("ddl.initSql", "${HOME}/initSql");
props.setProperty("ddl.initSql", "${user.home}" + fileSeparator + "initSql");
DatabaseConfig config = new DatabaseConfig();
config.loadFromProperties(props);
String ddlInitSql = config.getDdlInitSql();
assertThat(ddlInitSql).isEqualTo(home+"/initSql");
assertThat(ddlInitSql).isEqualTo(home + fileSeparator + "initSql");
}
@Test
@@ -50,30 +50,31 @@ public class PropertiesWrapperTest {
@Test
public void testGetProperties() {
String home = System.getenv("HOME");
String home = System.getProperty("user.home");
String tmpDir = System.getProperty("java.io.tmpdir");
String fileSeparator = System.getProperty("file.separator");
Properties properties = new Properties();
properties.put("someBasic", "hello");
properties.put("someInt", "42");
properties.put("someDouble", "5.5");
properties.put("somePath", "${HOME}/hello");
properties.put("someSystemProp", "/aaa/${java.io.tmpdir}/bbb");
properties.put("somePath", "${user.home}" + fileSeparator + "hello");
properties.put("someSystemProp", fileSeparator + "aaa" + fileSeparator + "${java.io.tmpdir}" + fileSeparator + "bbb");
Properties evalCopy = Config.asConfiguration().eval(properties);
PropertiesWrapper pw = new PropertiesWrapper("pref", "myserver", evalCopy, null);
assertEquals(42, pw.getInt("someInt", 99));
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
assertEquals(home + "/hello", pw.get("somePath", null));
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
pw = new PropertiesWrapper(evalCopy, null);
assertEquals(42, pw.getInt("someInt", 99));
assertEquals(Double.valueOf(5.5D), (Double.valueOf(pw.getDouble("someDouble", 99.9D))));
assertEquals(home + "/hello", pw.get("somePath", null));
assertEquals("/aaa/" + tmpDir + "/bbb", pw.get("someSystemProp"));
assertEquals(home + fileSeparator + "hello", pw.get("somePath", null));
assertEquals(fileSeparator + "aaa" + fileSeparator + tmpDir + fileSeparator + "bbb", pw.get("someSystemProp"));
}
}
@@ -2,28 +2,34 @@ package io.ebean.config.dbplatform;
import io.ebean.config.PlatformConfig;
import io.ebean.config.dbplatform.oracle.Oracle11Platform;
import io.ebean.config.dbplatform.oracle.Oracle12Platform;
import io.ebean.config.dbplatform.oracle.OraclePlatform;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class OraclePlatformTest {
class OraclePlatformTest {
@Test
public void columnAliasPrefix_Oracle11Platform() {
void columnAliasPrefix_Oracle11Platform() {
Oracle11Platform platform11 = new Oracle11Platform();
assertThat(platform11.columnAliasPrefix).isEqualTo("c");
}
@Test
public void columnAliasPrefix_OraclePlatform() {
OraclePlatform platform = new OraclePlatform();
assertThat(platform.columnAliasPrefix).isEqualTo("c");
void columnAliasPrefix_Oracle12Platform() {
Oracle12Platform platform12 = new Oracle12Platform();
assertThat(platform12.columnAliasPrefix).isEqualTo("c");
}
@Test
public void uuid_default() {
void columnAliasPrefix_OraclePlatform() {
OraclePlatform platform = new OraclePlatform();
assertThat(platform.columnAliasPrefix).isNull();
}
@Test
void uuid_default() {
OraclePlatform platform = new OraclePlatform();
platform.configure(new PlatformConfig(), false);
DbPlatformType dbType = platform.getDbTypeMap().get(DbPlatformType.UUID);
@@ -31,8 +37,7 @@ public class OraclePlatformTest {
}
@Test
public void uuid_as_binary() {
void uuid_as_binary() {
OraclePlatform platform = new OraclePlatform();
PlatformConfig config = new PlatformConfig();
config.setDbUuid(PlatformConfig.DbUuid.AUTO_BINARY);
@@ -4,24 +4,22 @@ import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import io.ebean.ModifyAwareType;
import io.ebean.text.json.EJson;
import io.ebean.util.IOUtils;
import io.ebeaninternal.json.ModifyAwareMap;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringReader;
import java.io.Writer;
import java.nio.file.Files;
import java.util.*;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.*;
public class EJsonTests {
private static final Logger log = LoggerFactory.getLogger(EJsonTests.class);
@Test
public void test_map_simple() throws IOException {
@@ -46,15 +44,13 @@ public class EJsonTests {
public void write_withWriter_expect_writerNotClosed() throws IOException {
File temp = Files.createTempFile("some", ".json").toFile();
FileWriter writer = new FileWriter(temp);
Map<String,Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EJson.write(map, writer);
writer.write("The end.");
writer.flush();
writer.close();
log.info("write to file {}", temp.getAbsolutePath());
try (Writer writer = IOUtils.newWriter(temp)) {
Map<String, Object> map = new LinkedHashMap<>();
map.put("foo", "bar");
EJson.write(map, writer);
writer.write("The end.");
}
assertThat(temp).hasContent("{\"foo\":\"bar\"}The end.");
}
@Test
@@ -0,0 +1,87 @@
package io.ebean.test.config.platform;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class DockerHostTest {
@Test
void runningInDocker_when_false_alwaysUseLocalhost() {
DockerHost dockerHost = new DockerHost();
assertFalse(dockerHost.runningInDocker());
assertEquals("localhost", dockerHost.dockerHost("foo"));
}
@Test
void runningInDocker_when_true_useExplicit() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
assertEquals("my-host", dockerHost.dockerHost("my-host"));
}
@Disabled
@Test
void runningInDocker_when_trueAndLinux_useDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
assertEquals("172.17.0.1", dockerHost.dockerHost(null));
}
@Test
void runningInDocker_when_windowsDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "win");
try {
assertEquals("host.docker.internal",dockerHost.defaultDockerHost());
assertEquals("host.docker.internal", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
@Test
void runningInDocker_when_macDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "mac");
try {
assertEquals("host.docker.internal",dockerHost.defaultDockerHost());
assertEquals("host.docker.internal", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
@Test
void runningInDocker_when_linuxDefault() {
TDDockerHost dockerHost = new TDDockerHost();
assertTrue(dockerHost.runningInDocker());
String origName = System.getProperty("os.name");
System.setProperty("os.name", "linux");
try {
assertEquals("172.17.0.1",dockerHost.defaultDockerHost());
assertEquals("172.17.0.1", dockerHost.dockerHost(null));
} finally {
System.setProperty("os.name", origName);
}
}
static class TDDockerHost extends DockerHost {
@Override
boolean initInDocker() {
return true;
}
}
}
@@ -11,6 +11,7 @@ import org.tests.model.basic.ResetBasicData;
import org.tests.model.basic.TBytesOnly;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.List;
@@ -94,7 +95,7 @@ public class CachedBeanDataSerializeTest extends BaseTestCase {
TBytesOnly bean = new TBytesOnly();
bean.setId(42);
bean.setContent(stringContent.getBytes("UTF-8"));
bean.setContent(stringContent.getBytes(StandardCharsets.UTF_8));
BeanDescriptor<TBytesOnly> desc = getBeanDescriptor(TBytesOnly.class);
CachedBeanData extract = CachedBeanDataFromBean.extract(desc, (EntityBean) bean);
@@ -5,25 +5,32 @@ import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BasicProfileLocationTest {
class BasicProfileLocationTest {
@Test
public void obtain() {
void obtain() {
DProfileLocation loc = new DTimedProfileLocation(12, "foo", MetricFactory.get().createTimedMetric("junk"));
String javaVersion = System.getProperty("java.version");
assertThat(loc.obtain()).isTrue();
assertThat(loc.fullLocation()).endsWith(":12)");
if (System.getProperty("java.version").startsWith("1.8")) {
if (javaVersion.startsWith("1.8")) {
assertThat(loc.fullLocation()).endsWith("invoke0(Native Method:12)");
assertThat(loc.location()).isEqualTo("sun.reflect.NativeMethodAccessorImpl.invoke0");
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
} else if (javaVersion.startsWith("18")){
assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)");
assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke");
assertThat(loc.label()).isEqualTo("DirectMethodHandleAccessor.invoke");
} else {
assertThat(loc.fullLocation()).endsWith("jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method:12)");
assertThat(loc.location()).isEqualTo("java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0");
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
}
assertThat(loc.label()).isEqualTo("NativeMethodAccessorImpl.invoke0");
}
@Test
public void basic_trimPackage() {
void basic_trimPackage() {
BasicProfileLocation loc = new BasicProfileLocation("com.foo.Bar.all");
assertThat(loc.obtain()).isFalse();
@@ -33,7 +40,7 @@ public class BasicProfileLocationTest {
}
@Test
public void basic_trimSinglePackage() {
void basic_trimSinglePackage() {
BasicProfileLocation loc = new BasicProfileLocation("foo.Bar.all");
assertThat(loc.obtain()).isFalse();
@@ -5,6 +5,7 @@ import io.ebean.config.EncryptKey;
import org.junit.jupiter.api.Test;
import org.tests.basic.encrypt.BasicEncryptKey;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import static org.assertj.core.api.Assertions.assertThat;
@@ -19,7 +20,7 @@ public class TestSimpleEncryptor extends BaseTestCase {
EncryptKey key = new BasicEncryptKey("hello");
byte[] data = "test123".getBytes();
byte[] data = "test123".getBytes(StandardCharsets.UTF_8);
byte[] ecData = e.encrypt(data, key);
@@ -15,6 +15,8 @@ import org.tests.model.ivo.converter.MoneyTypeConverter;
import javax.persistence.EnumType;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Calendar;
import java.util.GregorianCalendar;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
@@ -29,7 +31,6 @@ public class TestTypeManager extends BaseTestCase {
DefaultTypeManager typeManager = createTypeManager();
ScalarType<?> type = typeManager.createEnumScalarType(MyEnum.class, null);
typeManager.addEnumType(type, MyEnum.class);
Object val = type.read(new DummyDataReader("A"));
assertThat(val).isEqualTo(MyEnum.Aval);
@@ -131,6 +132,13 @@ public class TestTypeManager extends BaseTestCase {
return new DefaultTypeManager(config, bootupClasses);
}
@Test
public void testCalendar() throws SQLException {
DefaultTypeManager typeManager = createTypeManager();
ScalarType<?> typeB = typeManager.getScalarType(GregorianCalendar.class);
assertThat(typeB).isInstanceOf(ScalarTypeCalendar.class);
}
/**
* Test double DataReader implementation.
*/
@@ -0,0 +1,22 @@
package main;
import io.ebean.docker.commands.Db2Config;
import io.ebean.docker.commands.Db2Container;
public class StartDb2 {
public static void main(String[] args) {
Db2Config config = new Db2Config("11.5.6.0a");
config.setDbName("unit");
config.setUser("unit");
config.setPassword("unit");
// to change collation, charset and other parameters like pagesize:
config.setCreateOptions("USING CODESET UTF-8 TERRITORY DE COLLATE USING IDENTITY PAGESIZE 32768");
config.setConfigOptions("USING STRING_UNITS CODEUNITS32");
Db2Container container = new Db2Container(config);
container.startWithDropCreate();
}
}
@@ -8,12 +8,14 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteImportedPartial extends BaseTestCase {
@Test
public void test() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
Integer id = persistentFile.getId();
@@ -8,13 +8,15 @@ import org.tests.model.basic.PersistentFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt", new PersistentFileContent(
"test".getBytes()));
"test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
Integer id = persistentFile.getId();
@@ -8,16 +8,18 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNull;
import java.nio.charset.StandardCharsets;
public class TestDeleteOneToOneMultiple extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
// PFile persistentFile = new PFile();
// persistentFile.setName("test.txt");
// PFileContent content = new PFileContent();
// content.setContent("test".getBytes());
// content.setContent("test".getBytes(StandardCharsets.UTF_8));
// persistentFile.setFileContent(content);
DB.save(persistentFile);
@@ -13,13 +13,12 @@ import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.*;
public class TestLoadBeanCache extends BaseTestCase {
class TestLoadBeanCache extends BaseTestCase {
@Test
public void testLoad() {
void testLoad() {
ResetBasicData.reset();
@@ -35,32 +34,29 @@ public class TestLoadBeanCache extends BaseTestCase {
// this will hit the cache
Country nz = DB.find(Country.class, "NZ");
assertTrue(loadedNz == nz);
assertSame(loadedNz, nz);
}
@Test
public void testLoadWithFindMap() {
void testLoadWithFindMap() {
ResetBasicData.reset();
List<Object> ids = DB.find(Customer.class).findIds();
assertEquals(ids.size(), 4);
assertThat(ids).isNotEmpty();
DB.getDefault().pluginApi().cacheManager().clearAll();
// hit database
LoggedSql.start();
DB.find(Customer.class).where().idIn(ids).findMap();
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
// hit beanCache
LoggedSql.start();
DB.find(Customer.class).where().idIn(ids).findMap();
sql = LoggedSql.stop();
assertThat(sql).hasSize(0);
}
}
@@ -8,12 +8,14 @@ import org.tests.model.basic.PersistentFileContent;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.charset.StandardCharsets;
public class TestSaveDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt",
new PersistentFileContent("test".getBytes()));
new PersistentFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
DB.delete(persistentFile);
@@ -22,7 +24,7 @@ public class TestSaveDeleteOneToOne extends BaseTestCase {
@Test
public void testCreateLoadDeletePersistentFile() {
PersistentFile persistentFile = new PersistentFile("test.txt",
new PersistentFileContent("test".getBytes()));
new PersistentFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
@@ -8,11 +8,13 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.charset.StandardCharsets;
public class TestSaveDeleteOneToOneMultiple extends BaseTestCase {
// public void testCreateDeletePFile() {
// PFile persistentFile = new PFile("test.txt",
// new PFileContent("test".getBytes()));
// new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
//
// DB.save(persistentFile);
// DB.delete(persistentFile);
@@ -21,7 +23,7 @@ public class TestSaveDeleteOneToOneMultiple extends BaseTestCase {
@Test
public void testCreateLoadDeletePFile() {
PFile persistentFile = new PFile("test.txt",
new PFileContent("test".getBytes()));
new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
DB.save(persistentFile);
@@ -5,13 +5,16 @@ import io.ebean.BaseTestCase;
import io.ebean.DB;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.TWithPreInsert;
import org.tests.model.basic.TWithPreInsertChild;
import org.tests.model.basic.event.TWithPreInsertPersistAdapter;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class TestPreInsertValidation extends BaseTestCase {
class TestPreInsertValidation extends BaseTestCase {
@Test
public void test() {
void test() {
TWithPreInsert e = new TWithPreInsert();
e.setTitle("Mister");
@@ -22,15 +25,56 @@ public class TestPreInsertValidation extends BaseTestCase {
// the save worked and name set in preInsert
assertNotNull(e.getId());
assertNotNull(e.getName());
assertThat(e.requestCascadeState()).isEqualTo(2);
TWithPreInsert e1 = DB.find(TWithPreInsert.class, e.getId());
assert e1 != null;
e1.setTitle("Missus");
DB.save(e1);
assertThat(e1.requestCascadeState()).isEqualTo(12);
}
@Test
public void testStatelessUpdate() {
void test_cascade() {
TWithPreInsert e = new TWithPreInsert();
e.setTitle("ParentCascading");
e.children().add(new TWithPreInsertChild("Child0"));
// the perInsert should populate the
// name with should not be null
DB.save(e);
// the save worked and name set in preInsert
assertNotNull(e.getId());
assertNotNull(e.getName());
assertThat(e.requestCascadeState()).isEqualTo(2);
assertThat(e.children().get(0).requestCascadeState()).isEqualTo(1);
TWithPreInsert e1 = DB.find(TWithPreInsert.class, e.getId());
assert e1 != null;
e1.setTitle("ParentCascading-changed");
TWithPreInsertChild childBean = e1.children().get(0);
childBean.setName("Child0-changed");
DB.save(e1);
assertThat(e1.requestCascadeState()).isEqualTo(12);
assertThat(childBean.requestCascadeState()).isEqualTo(11);
DB.delete(e1);
assertThat(e1.requestCascadeState()).isEqualTo(22);
// assert that isCascade() was true for the child bean
assertThat(TWithPreInsertPersistAdapter.cascadeDelete).hasSize(1);
String deleteCascade = TWithPreInsertPersistAdapter.cascadeDelete.get(0);
assertThat(deleteCascade).isEqualTo("class org.tests.model.basic.TWithPreInsertChild:1");
}
@Test
void testStatelessUpdate() {
TWithPreInsert e = new TWithPreInsert();
e.setName("BeanForUpdateTest");
@@ -26,7 +26,7 @@ public class TestDefaults extends BaseTestCase {
final List<String> current = LoggedSql.collect();
assertThat(current).isNotEmpty();
if (isMySql() || isMariaDB()) {
if (isMySql() || isMariaDB() || isOracle()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft values (default);");
} else if (isSqlServer()) {
assertThat(current.get(0)).contains("insert into defaults_model_draft (id) values (?)");
@@ -9,12 +9,14 @@ import org.tests.model.basic.PFileContent;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.nio.charset.StandardCharsets;
public class TestConstructorPutfieldReplacement extends BaseTestCase {
@Test
public void test() {
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes()));
PFile persistentFile = new PFile("test.txt", new PFileContent("test".getBytes(StandardCharsets.UTF_8)));
EntityBean eb = (EntityBean) persistentFile;
EntityBeanIntercept ebi = eb._ebean_getIntercept();
@@ -14,6 +14,8 @@ import org.tests.idkeys.db.GenKeySeqB;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
@@ -24,6 +26,7 @@ public class TestGeneratedKeys extends BaseTestCase {
@ForPlatform(Platform.H2) // readSequenceValue is H2 specific
public void testGenKeySeqA() throws SQLException {
assumeTrue(idType() == IdType.SEQUENCE);
SpiEbeanServer server = spiEbeanServer();
try (Transaction tx = server.beginTransaction()) {
@@ -69,20 +72,34 @@ public class TestGeneratedKeys extends BaseTestCase {
}
private long readSequenceValue(Transaction tx, String sequence) throws SQLException {
Statement stm = null;
try {
stm = tx.connection().createStatement();
ResultSet rs = stm.executeQuery("select currval('" + sequence + "')");
rs.next();
String sql;
switch (spiEbeanServer().databasePlatform().getPlatform().base()) {
case H2 :
sql = "select currval('" + sequence + "')";
break;
case DB2 :
sql = "values previous value for " + sequence;
break;
case SQLSERVER :
sql = "select current_value from sys.sequences where name = '" + sequence + "'";
break;
case MARIADB :
throw new UnsupportedOperationException("reading sequence value outside of the current connection is not supported. "
+ "See https://mariadb.com/kb/en/previous-value-for-sequence_name/#description");
default :
throw new UnsupportedOperationException("reading sequence value from "
+ spiEbeanServer().databasePlatform().getPlatform()
+ " is not supported.");
}
try (Statement stm = tx.connection().createStatement()) {
ResultSet rs = stm.executeQuery(sql);
rs.next();
return rs.getLong(1);
} finally {
if (stm != null) {
try {
stm.close();
} catch (SQLException e) {
}
}
}
}
@@ -109,5 +126,25 @@ public class TestGeneratedKeys extends BaseTestCase {
assertNotNull(al.getId());
}
}
@Test
@ForPlatform({Platform.H2, Platform.MARIADB, Platform.SQLSERVER, Platform.DB2})
public void testGeneratedKeys() throws SQLException {
assumeTrue(idType() == IdType.SEQUENCE);
SpiEbeanServer server = spiEbeanServer();
List<Long> idList = new ArrayList<>(52);
try (Transaction tx = server.beginTransaction()) {
// bigger than increment
for (int i = 1; i < 52; i++) {
GenKeySeqA gks = new GenKeySeqA();
gks.setDescription("my description " + i);
server.save(gks);
assertFalse(idList.contains(gks.getId()));
idList.add(gks.getId());
}
}
}
}
@@ -0,0 +1,63 @@
package org.tests.json;
import io.ebean.Database;
import io.ebean.DatabaseFactory;
import io.ebean.ValuePair;
import io.ebean.annotation.ForPlatform;
import io.ebean.annotation.MutationDetection;
import io.ebean.annotation.Platform;
import io.ebean.config.DatabaseConfig;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.tests.model.json.EBasicJsonList;
import java.util.List;
import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
class TestJsonSourceDefault {
@Test
@ForPlatform(Platform.H2)
@Disabled
void testDirtyValues_diffSource() {
DatabaseConfig config = new DatabaseConfig();
config.getDataSourceConfig()
.setUsername("sa")
.setPassword("")
.setUrl("jdbc:h2:mem:testJsonSourceDirtyValues");
config.setName("jsonSource");
config.setDefaultServer(false);
config.setRegister(false);
config.setDdlGenerate(true);
config.setDdlRun(true);
config.setDdlExtra(false);
config.addClass(EBasicJsonList.class);
config.setJsonMutationDetection(MutationDetection.SOURCE);
Database db = DatabaseFactory.create(config);
try {
assertThat(db).isNotNull();
EBasicJsonList bean = new EBasicJsonList();
bean.getTags().add("aa");
bean.getTags().add("bb");
db.save(bean);
bean = db.find(EBasicJsonList.class, bean.getId());
bean.getTags().add("cc");
final Map<String, ValuePair> dirtyValues = db.beanState(bean).dirtyValues();
assertThat(dirtyValues).containsOnlyKeys("tags");
final ValuePair diff = dirtyValues.get("tags");
assertThat(diff.getOldValue()).isInstanceOf(List.class).asList().containsExactly("aa", "bb");
assertThat(diff.getNewValue()).isInstanceOf(List.class).asList().containsExactly("aa", "bb", "cc");
} finally {
if (db != null) {
db.shutdown();
}
}
}
}

Some files were not shown because too many files have changed in this diff Show More