Compare commits

..
40 Commits
Author SHA1 Message Date
Rob Bygrave c9a6f822ac Version 16.1.0 2025-09-19 18:48:28 +12:00
Rob BygraveandGitHub 2231ef9fd1 Bump ebean-agent to 16.1.0 with Java 25 support (#3680)
Note that the IntelliJ plugin has been updated and published. It should be public in a few days.
2025-09-19 16:25:24 +12:00
Rob Bygrave 3ff1905318 Bump ebean-test-containers to 7.15 with updated ClickHouse support 2025-09-19 16:25:00 +12:00
Rob BygraveandGitHub 9b4fecff96 Add support for AutoCommit true transactions (#3679)
* Add support for AutoCommit true transactions

* Update DocStoreTransactionManager
2025-09-19 16:22:59 +12:00
Rob BygraveandGitHub 6f356fd55e #3674 Add @Nullable to Query getId(), getForUpdateLockWait(), getForUpdateLockType() (#3675)
These methods return nullable results, add JSpecify `@Nullable` to correctly indicate this.
2025-09-06 17:22:13 +12:00
Rob BygraveandGitHub 591f260f5b Retain filterMany expression when select fetchGroup applied after filterMany (#3673) 2025-09-02 22:35:43 +12:00
Rob Bygrave b361b10571 Version 16.0.1 2025-09-02 14:09:03 +12:00
Rob BygraveandGitHub c0e4e548ee Update the kotlin-maven-plugin for tests and use EA maven profile (#3671)
* Update the kotlin-maven-plugin for tests

* Add a profile for EA that excludes kotlin-querybean-generator

* For build workflow use maven profile "default"

To ensure the kotlin-querybean-generator, test modules run

* For build workflow use maven profile "default"

To ensure the kotlin-querybean-generator, test modules run
2025-09-02 14:04:59 +12:00
Rob Bygrave 92f3245919 Bump ebean-agent to 16.0.1 2025-09-02 13:37:45 +12:00
Rob BygraveandGitHub 59c2290916 Bump ebean-migration dependency, fix for setting dbSchema on migrations (#3670)
Ref: https://github.com/ebean-orm/ebean-migration/pull/163
2025-09-02 12:52:41 +12:00
Rob BygraveandGitHub 1135eb3f99 #3665 Fix for delete() Skips Bean due to Hash Collision (#3669)
Change the underlying storage of deleting beans to be by type by id so:

  private Map<Class<?>, Set<Object>> deletingBeans;
2025-08-31 22:32:27 +12:00
Rob BygraveandGitHub 1dccdff7bf #3664 Fix / support for extra JoinColumns on ManyToOne (#3668)
* #3664 Fix / support for extra JoinColumns on ManyToOne

Allows for extra JoinColumns on ManyToOne. The extra JoinColumn(s) are
expected to be useful for the case of table partitioning where the extra
join column is used to partition the table. In the test case, the partition
column would be the org_id column and common to both tables (same partition key).

* #3664 Fix / support for extra JoinColumns on ManyToOne

Allows for extra JoinColumns on ManyToOne. The extra JoinColumn(s) are
expected to be useful for the case of table partitioning where the extra
join column is used to partition the table. In the test case, the partition
column would be the org_id column and common to both tables (same partition key).

* #3664 Extend test

* #3664 Tidy up test
2025-08-31 12:52:17 +12:00
Rob BygraveandGitHub 5f74a53e3e #3666 Fix for NPE with filterMany() containing or() (#3667)
For FilterMany with QueryBeans, it creates a queryBean to build the filterMany predicates with. This query bean needed 2 changes for this fix:

1. Needs to set it's internal "root" such that it supports chaining (required for or() etc)
2. The ExpressionFactory needs to be explicitly passed to the expression list (rather than get it from the query which is actually null in this case).
2025-08-31 10:08:07 +12:00
Rob Bygrave 1f9e652ea9 Version 16.0.0 2025-08-25 08:21:49 +12:00
Rob Bygrave 4e592c97ff Update how to deploy 2025-08-05 23:30:18 +12:00
Rob Bygrave 760d19a10d Update how to deploy 2025-08-05 23:16:42 +12:00
Rob Bygrave d2693c3ff2 Version 16.0.0-RC4 2025-08-05 23:15:20 +12:00
Rob BygraveandGitHub 3324b2bda4 Use autocommit false with findIterate for Postgres (#3662)
* Use autocommit false with findIterate for Postgres

* Use autocommit false with findIterate for Postgres

* Use autocommit false with FindDto queries for Postgres

* Use autocommit false with SqlQuery findIterate queries for Postgres

* Ensure that TransactionFactory.createReadOnlyTransaction() returns an ImplicitReadOnlyTransaction

This change changes TransactionFactoryTenant.createReadOnlyTransaction() to return a ImplicitReadOnlyTransaction, as that is now used to support Postgres use of cursors with findIterate style queries.
2025-08-05 23:03:28 +12:00
Rob BygraveandGitHub 1b5e066562 #3654 Fix querybean-generator compiler warning for unclaimed annotations (#3655)
warning: No processor claimed any of these annotations: /io.ebean.typequery.TypeQueryBean,/io.ebean.typequery.Generated

This fix is required when the compiler is run with -Werror specified

An alternative workaround is to use compiler arg -Xlint:-processing rather than -Xlint:all
2025-07-16 20:34:56 +12:00
Rob BygraveandGitHub 104e4ec756 Bump ebean-test-containers to 7.14 - Yugabyte read committed support enabled by default (#3651) 2025-07-14 09:03:39 +12:00
Rob Bygrave 74a2967a6e Tests Yugabyte - comment out the TestQueryForUpdate using repeatable read
... as its noise there is anyone else reads the logs
2025-07-12 09:38:06 +12:00
Rob Bygrave e693b12a97 Tests DB2 - ignore TestRawExpressionInterpolation for DB2 2025-07-12 09:30:16 +12:00
Rob Bygrave 48fb9b34bb Tests Yugabyte - faster test using forUpdate 2025-07-12 09:18:01 +12:00
Rob Bygrave f64400400a Tests Oracle - ignore the TestRawExpressionInterpolation for Oracle 2025-07-12 09:09:34 +12:00
Rob Bygrave d7cc081942 Tests Yugabyte - see if everything else passes 2025-07-12 09:04:02 +12:00
Rob Bygrave 3351548b60 Fix use of JSpecify Nullable annotation in query bean generation 2025-07-11 23:45:31 +12:00
Rob Bygrave 8d9858f57a Test only - Update logging for test TestQueryForUpdate 2025-07-11 23:35:03 +12:00
Rob Bygrave 9b520bc176 Bump avaje-config to 4.1 2025-07-11 23:22:16 +12:00
Rob Bygrave 44fd8e3a56 Adjust TestQueryForUpdate for Yugabyte - use markAsDirty on repeatable read test 2025-07-11 23:11:45 +12:00
Rob Bygrave 6910016c4d Adjust TestQueryForUpdate for Yugabyte - use markAsDirty
To see if the update has an impact on the 2nd thread waiting
2025-07-11 22:58:02 +12:00
Rob Bygrave 5f8a3c0591 Adjust TestQueryForUpdate for Yugabyte - check repeatable read isolation level 2025-07-11 22:05:31 +12:00
Rob BygraveandGitHub 0ae6956c1c Bump ebean-datasource 10.1 with support for initialConnections (#3650)
So in a K8s deployment, this adds support for having an initial number of connections to create initially (higher that min connections). This allows for a smoother deployment, by effectively having initially more connections than min in order to immediately take production load, and then over time trim back down towards the min connections.

So in k8s I am setting min, initial and max connections, where initial connections is high enough to take full production load straight after readiness true.
2025-07-11 21:26:58 +12:00
Rob Bygrave 2e9c5d8548 Merge branch 'query-cache-oom-for-too-large-beans' 2025-07-11 21:19:21 +12:00
Rob Bygrave 93edc840b3 Add a test that hits the new branch of code 2025-07-11 21:18:00 +12:00
34311785fa Fix Jackson NCDF Error (#3639)
* fix jackson NCDF error

split jackson SPI impl into it's own module

* Restore format

* Restore format

* Trim up dependencies

* Rename module to ebean-core-json

---------

Co-authored-by: Rob Bygrave <robin.bygrave@gmail.com>
2025-07-11 20:53:25 +12:00
Rob Bygrave 63929f8ff3 Bump test Yugabyte version to 2.20.11.0-b34 2025-07-11 20:26:12 +12:00
Jonas Fröhler d918c5117f no import changes 2025-07-01 09:05:48 +02:00
Jonas Fröhler dd845a7b0c Fix imports 2025-07-01 09:02:26 +02:00
Jonas Fröhler df0e4d57f0 Clean up 2025-06-27 12:17:19 +02:00
Jonas Fröhler 9c7fa25d49 Query Cache OOM test and potential draft for the fix 2025-06-27 12:14:01 +02:00
123 changed files with 993 additions and 543 deletions
+1 -1
View File
@@ -40,5 +40,5 @@ jobs:
# - name: Maven single test
# run: mvn --batch-mode clean verify -Dtest="io.ebeaninternal.server.core.DefaultServer_getReferenceTest" -DfailIfNoTests=false
- name: Build with Maven
run: mvn -T 8 clean test
run: mvn -T 8 clean test -Pdefault
+1 -1
View File
@@ -37,5 +37,5 @@ jobs:
- name: Maven version
run: mvn --version
- name: Build with Maven
run: mvn -T 8 test
run: mvn test -Pea
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-clickhouse</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-db2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-hana</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mariadb</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-mysql</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -22,13 +22,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -47,19 +47,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-net-postgis-types</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-nuodb</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-oracle</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -22,13 +22,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -47,19 +47,19 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis-types</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlite</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -42,13 +42,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<relativePath>../..</relativePath>
</parent>
@@ -17,13 +17,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -41,7 +41,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -60,13 +60,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+1 -1
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<artifactId>composites</artifactId>
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean api</name>
@@ -35,7 +35,7 @@
<dependency>
<groupId>io.avaje</groupId>
<artifactId>avaje-config</artifactId>
<version>4.0</version>
<version>4.1</version>
</dependency>
<dependency>
@@ -1,6 +1,7 @@
package io.ebean;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;
/**
* Object relational query for finding a List, Set, Map or single entity bean.
@@ -310,6 +311,7 @@ public interface Query<T> extends CancelableQuery, QueryBuilder<Query<T>, T> {
/**
* Return the Id value.
*/
@Nullable
Object getId();
/**
@@ -446,11 +448,13 @@ public interface Query<T> extends CancelableQuery, QueryBuilder<Query<T>, T> {
/**
* Return the "for update" wait mode to use.
*/
@Nullable
LockWait getForUpdateLockWait();
/**
* Return the lock type (strength) to use with "for update".
*/
@Nullable
LockType getForUpdateLockType();
/**
@@ -167,6 +167,7 @@ public class DatabasePlatform {
* findIterate() and findVisit().
*/
protected boolean forwardOnlyHintOnFindIterate;
protected boolean autoCommitFalseOnFindIterate;
/**
* If set then use the CONCUR_UPDATABLE hint when creating ResultSets.
@@ -528,6 +529,10 @@ public class DatabasePlatform {
this.forwardOnlyHintOnFindIterate = forwardOnlyHintOnFindIterate;
}
public boolean autoCommitFalseOnFindIterate() {
return autoCommitFalseOnFindIterate;
}
/**
* Return true if the ResultSet CONCUR_UPDATABLE Hint should be used on
* createNativeSqlTree() PreparedStatements.
@@ -780,4 +785,5 @@ public class DatabasePlatform {
public String inlineSqlHint(String hint) {
return "/*+ " + hint + " */ ";
}
}
+26 -26
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean bom</name>
@@ -89,25 +89,25 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -125,13 +125,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -155,37 +155,37 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>kotlin-querybean-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-redis</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-spring-txn</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<!-- platforms -->
@@ -193,79 +193,79 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-clickhouse</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-db2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-h2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-hana</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-mariadb</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-mysql</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-nuodb</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-oracle</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-postgis-types</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-sqlite</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-sqlserver</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
</dependencies>
+32
View File
@@ -0,0 +1,32 @@
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.ebean</groupId>
<artifactId>ebean-parent</artifactId>
<version>16.1.0</version>
</parent>
<artifactId>ebean-core-json</artifactId>
<name>ebean-core-json</name>
<scm>
<developerConnection>scm:git:git@github.com:ebean-orm/ebean.git</developerConnection>
<tag>HEAD</tag>
</scm>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.1.0</version>
</dependency>
<!-- Jackson core used internally by Ebean -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project>
@@ -8,11 +8,7 @@ import io.ebean.service.SpiJsonService;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
/**
* Utility that converts between JSON content and simple java Maps/Lists.
@@ -52,8 +48,8 @@ public final class DJsonService implements SpiJsonService {
}
/**
* Parse the json and return as a Map additionally specifying if the returned map should
* be modify aware meaning that it can detect when it has been modified.
* Parse the json and return as a Map additionally specifying if the returned map should be modify
* aware meaning that it can detect when it has been modified.
*/
@Override
public Map<String, Object> parseObject(String json, boolean modifyAware) throws IOException {
@@ -94,9 +90,8 @@ public final class DJsonService implements SpiJsonService {
/**
* Parse the json and return as a Map taking a JsonParser and a starting token.
* <p>
* Used when the first token is checked to see if the value is null prior to calling this.
* </p>
*
* <p>Used when the first token is checked to see if the value is null prior to calling this.
*/
@Override
public Map<String, Object> parseObject(JsonParser parser, JsonToken token) throws IOException {
@@ -8,15 +8,23 @@ import io.ebean.ModifyAwareType;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.*;
final class EJsonReader {
static final JsonFactory json = new JsonFactory();
private final JsonParser parser;
private final boolean modifyAware;
private final ModifyAwareFlag modifyAwareOwner;
private int depth;
private Stack stack;
private Context currentContext;
EJsonReader(JsonParser parser, boolean modifyAware) {
this.parser = parser;
this.modifyAware = modifyAware;
this.modifyAwareOwner = modifyAware ? new ModifyAwareFlag() : null;
}
@SuppressWarnings("unchecked")
static Map<String, Object> parseObject(String json, boolean modifyAware) throws IOException {
@@ -102,24 +110,6 @@ final class EJsonReader {
return new EJsonReader(parser, modifyAware).parseJson(token);
}
private final JsonParser parser;
private final boolean modifyAware;
private final ModifyAwareFlag modifyAwareOwner;
private int depth;
private Stack stack;
private Context currentContext;
EJsonReader(JsonParser parser, boolean modifyAware) {
this.parser = parser;
this.modifyAware = modifyAware;
this.modifyAwareOwner = (modifyAware) ? new ModifyAwareFlag() : null;
}
private void startArray() {
depth++;
stack.push(currentContext);
@@ -197,7 +187,6 @@ final class EJsonReader {
*/
private void processJsonToken(JsonToken token) throws IOException {
switch (token) {
case START_ARRAY:
startArray();
break;
@@ -273,17 +262,17 @@ final class EJsonReader {
}
}
private static abstract class Context {
private abstract static class Context {
Context next;
abstract void popContext(Context temp);
abstract Object getValue();
abstract void setKey(String key);
abstract void setValue(Object value);
abstract void setKey(String key);
abstract void setValueNull();
}
@@ -312,13 +301,13 @@ final class EJsonReader {
}
@Override
void setKey(String key) {
this.key = key;
void setValue(Object value) {
map.put(key, value);
}
@Override
void setValue(Object value) {
map.put(key, value);
void setKey(String key) {
this.key = key;
}
@Override
@@ -364,5 +353,4 @@ final class EJsonReader {
// not expected
}
}
}
@@ -20,6 +20,11 @@ final class EJsonWriter {
* Base jsonFactory implementation used when it is not passed in.
*/
static final JsonFactory jsonFactory = new JsonFactory();
private final JsonGenerator jsonGenerator;
private EJsonWriter(JsonGenerator jsonGenerator) {
this.jsonGenerator = jsonGenerator;
}
static String write(Object object) throws IOException {
StringWriter writer = new StringWriter(200);
@@ -42,12 +47,6 @@ final class EJsonWriter {
new EJsonWriter(jsonGenerator).writeCollection(null, collection);
}
private final JsonGenerator jsonGenerator;
private EJsonWriter(JsonGenerator jsonGenerator) {
this.jsonGenerator = jsonGenerator;
}
private void writeJson(Object object) {
writeJson(null, object);
}
@@ -210,5 +209,4 @@ final class EJsonWriter {
}
jsonGenerator.writeEndObject();
}
}
@@ -22,5 +22,4 @@ public final class ModifyAwareFlag implements ModifyAwareType, Serializable {
public void setMarkedDirty(boolean markedDirty) {
this.markedDirty = markedDirty;
}
}
@@ -14,9 +14,8 @@ public final class ModifyAwareIterator<E> implements Iterator<E> {
/**
* Create with an Owner and the underlying Iterator this wraps.
* <p>
* The owner is notified of the removals.
* </p>
*
* <p>The owner is notified of the removals.
*/
public ModifyAwareIterator(ModifyAwareType owner, Iterator<E> it) {
this.owner = owner;
@@ -38,5 +37,4 @@ public final class ModifyAwareIterator<E> implements Iterator<E> {
owner.setMarkedDirty(true);
it.remove();
}
}
@@ -34,11 +34,11 @@ public final class ModifyAwareMap<K, V> implements Map<K, V>, ModifyAwareType, S
public boolean equals(Object o) {
if (this == o) return true;
if (o instanceof ModifyAwareMap) {
ModifyAwareMap<?,?> that = (ModifyAwareMap<?,?>) o;
ModifyAwareMap<?, ?> that = (ModifyAwareMap<?, ?>) o;
return Objects.equals(map, that.map);
}
if (!(o instanceof Map)) return false;
Map<?,?> that = (Map<?,?>) o;
Map<?, ?> that = (Map<?, ?>) o;
return Objects.equals(map, that);
}
@@ -112,7 +112,6 @@ public final class ModifyAwareMap<K, V> implements Map<K, V>, ModifyAwareType, S
map.putAll(m);
}
@Override
public void clear() {
if (!map.isEmpty()) {
@@ -135,5 +134,4 @@ public final class ModifyAwareMap<K, V> implements Map<K, V>, ModifyAwareType, S
public Set<Map.Entry<K, V>> entrySet() {
return new ModifyAwareSet<>(this, map.entrySet());
}
}
@@ -0,0 +1,9 @@
module io.ebean.core.json {
requires io.ebean.api;
requires transitive com.fasterxml.jackson.core;
exports io.ebeaninternal.json to io.ebean.test, io.ebean.core;
provides io.ebean.service.BootstrapService with io.ebeaninternal.json.DJsonService;
}
@@ -0,0 +1 @@
io.ebeaninternal.json.DJsonService
+2 -2
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<artifactId>ebean-core-type</artifactId>
@@ -16,7 +16,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
+12 -6
View File
@@ -3,7 +3,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<artifactId>ebean-core</artifactId>
@@ -22,7 +22,13 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-json</artifactId>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -46,7 +52,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -159,21 +165,21 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-sqlserver</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -1,5 +1,6 @@
package io.ebeaninternal.api;
import io.ebean.bean.EntityBean;
import java.util.ArrayList;
import java.util.List;
@@ -13,10 +14,23 @@ public final class BindValuesKey {
private final List<Object> values = new ArrayList<>();
private final SpiEbeanServer server;
public BindValuesKey(SpiEbeanServer server) {
this.server = server;
}
/**
* Add a bind value.
*/
public BindValuesKey add(Object value) {
if (value instanceof EntityBean) {
// only interested in id to keep the memory footprint low
Object id = server.beanId(value);
if (id != null) {
value = id;
}
}
values.add(value);
return this;
}
@@ -31,5 +45,4 @@ public final class BindValuesKey {
return values.hashCode();
}
}
@@ -65,12 +65,12 @@ public interface SpiTransaction extends Transaction {
* <p>
* This is to handle bi-directional relationships where both sides Cascade.
*/
void registerDeleteBean(Integer hash);
void registerDeleteBean(Class<?> type, Object id);
/**
* Return true if this is a bean that has already been saved/deleted.
*/
boolean isRegisteredDeleteBean(Integer hash);
boolean isRegisteredDeleteBean(Class<?> type, Object id);
/**
* Unregister the persisted beans. Expected after persisting top level beans
@@ -362,4 +362,14 @@ public interface SpiTransaction extends Transaction {
* Set the transaction to be inactive via external transaction manager.
*/
void deactivateExternal();
/**
* Set autocommit to false for a findIterate query.
* <p>
* This is done for specific platforms that need it, in order to make
* use cursors to stream a large or unbounded query result to the client.
*/
default void setAutoCommitOnFindIterate() {
throw new UnsupportedOperationException();
}
}
@@ -195,13 +195,13 @@ public abstract class SpiTransactionProxy implements SpiTransaction {
}
@Override
public void registerDeleteBean(Integer hash) {
transaction.registerDeleteBean(hash);
public void registerDeleteBean(Class<?> type, Object id) {
transaction.registerDeleteBean(type, id);
}
@Override
public boolean isRegisteredDeleteBean(Integer hash) {
return transaction.isRegisteredDeleteBean(hash);
public boolean isRegisteredDeleteBean(Class<?> type, Object id) {
return transaction.isRegisteredDeleteBean(type, id);
}
@Override
@@ -1,7 +1,6 @@
package io.ebeaninternal.server.core;
import io.ebean.CancelableQuery;
import io.ebean.Transaction;
import io.ebean.util.JdbcClose;
import io.ebeaninternal.api.*;
import io.ebeaninternal.server.persist.Binder;
@@ -98,6 +97,13 @@ public abstract class AbstractSqlQueryRequest implements CancelableQuery {
public void setDefaultFetchBuffer(int fetchSize) {
query.setDefaultFetchBuffer(fetchSize);
}
public void setAutoCommitOnFindIterate() {
if (createdTransaction) {
transaction.setAutoCommitOnFindIterate();
}
}
/**
* Close the underlying resources.
*/
@@ -301,12 +301,12 @@ public final class InternalConfiguration {
}
DtoQueryEngine createDtoQueryEngine() {
return new DtoQueryEngine(binder, config.getJdbcFetchSizeFindEach(), config.getJdbcFetchSizeFindList());
return new DtoQueryEngine(binder, config.getJdbcFetchSizeFindEach(), config.getJdbcFetchSizeFindList(), databasePlatform.autoCommitFalseOnFindIterate());
}
RelationalQueryEngine createRelationalQueryEngine() {
return new DefaultRelationalQueryEngine(binder, config.getDatabaseBooleanTrue(), config.getPlatformConfig().getDbUuid().useBinaryOptimized(),
config.getJdbcFetchSizeFindEach(), config.getJdbcFetchSizeFindList());
config.getJdbcFetchSizeFindEach(), config.getJdbcFetchSizeFindList(), databasePlatform.autoCommitFalseOnFindIterate());
}
OrmQueryEngine createOrmQueryEngine() {
@@ -786,4 +786,10 @@ public final class OrmQueryRequest<T> extends BeanRequest implements SpiOrmQuery
beanDescriptor.freeze(bean);
}
}
public void setAutoCommitOnFindIterate() {
if (createdTransaction) {
transaction.setAutoCommitOnFindIterate();
}
}
}
@@ -54,10 +54,6 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
* The unique id used for logging summary.
*/
private Object idValue;
/**
* Hash value used to handle cascade delete both ways in a relationship.
*/
private Integer beanHash;
private boolean statelessUpdate;
private boolean notifyCache;
/**
@@ -285,7 +281,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
private void onFailedUpdateUndoGeneratedProperties() {
for (BeanProperty prop : beanDescriptor.propertiesGenUpdate()) {
Object oldVal = intercept.origValue(prop.propertyIndex());
prop.setValue(entityBean, oldVal);
if (oldVal != null) {
prop.setValue(entityBean, oldVal);
}
}
}
@@ -553,34 +551,17 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
}
}
/**
* The hash used to register the bean with the transaction.
* <p>
* Takes into account the class type and id value.
*/
private Integer beanHash() {
if (beanHash == null) {
Object id = beanDescriptor.getId(entityBean);
int hc = 92821 * bean.getClass().getName().hashCode();
if (id != null) {
hc += id.hashCode();
}
beanHash = hc;
}
return beanHash;
}
public void registerDeleteBean() {
Integer hash = beanHash();
transaction.registerDeleteBean(hash);
final Object id = beanDescriptor.id(entityBean);
transaction.registerDeleteBean(beanDescriptor.type(), id);
}
public boolean isRegisteredForDeleteBean() {
if (transaction == null) {
return false;
} else {
Integer hash = beanHash();
return transaction.isRegisteredDeleteBean(hash);
final Object id = beanDescriptor.id(entityBean);
return transaction.isRegisteredDeleteBean(beanDescriptor.type(), id);
}
}
@@ -809,7 +790,9 @@ public final class PersistRequestBean<T> extends PersistRequest implements BeanP
public void checkRowCount(int rowCount) {
if (rowCount != 1 && rowCount != Statement.SUCCESS_NO_INFO) {
if (ConcurrencyMode.VERSION == concurrencyMode) {
onFailedUpdateUndoGeneratedProperties();
if (type == Type.UPDATE) {
onFailedUpdateUndoGeneratedProperties();
}
throw new OptimisticLockException("Data has changed. updated row count " + rowCount, null, bean);
} else if (rowCount == 0 && type == Type.UPDATE) {
throw new EntityNotFoundException("No rows updated");
@@ -436,14 +436,15 @@ public abstract class BeanPropertyAssoc<T> extends BeanProperty implements STree
}
TableJoinColumn[] cols = join.columns();
if (!idProp.isEmbedded()) {
// simple single scalar id
if (cols.length != 1) {
CoreLog.log.log(ERROR, "No Imported Id column for {0} in table {1}", idProp, join.getTable());
return null;
} else {
BeanProperty[] idProps = {idProp};
return createImportedScalar(owner, cols[0], idProps, others);
// simple single scalar id, match on the foreign column, allow extra TableJoinColumn for #3664
String matchColumn = idProp.dbColumn();
for (TableJoinColumn col : cols) {
if (matchColumn.equals(col.getForeignDbColumn())) {
return createImportedScalar(owner, col, new BeanProperty[]{idProp}, others);
}
}
CoreLog.log.log(ERROR, "No Imported Id column for {0} in table {1}", idProp, join.getTable());
return null;
} else {
// embedded id
BeanPropertyAssocOne<?> embProp = (BeanPropertyAssocOne<?>) idProp;
@@ -128,16 +128,6 @@ public class BeanPropertyAssocOne<T> extends BeanPropertyAssoc<T> implements STr
throw new PersistenceException("Cannot find imported id for " + fullName() + " from " + targetDescriptor
+ ". If using native-image, possibly missing reflect-config for the Id property.");
}
if (importedId.isScalar()) {
// limit JoinColumn mapping to the @Id / primary key
TableJoinColumn[] columns = tableJoin.columns();
String foreignJoinColumn = columns[0].getForeignDbColumn();
String foreignIdColumn = targetDescriptor.idProperty().dbColumn();
if (!foreignJoinColumn.equalsIgnoreCase(foreignIdColumn)) {
throw new PersistenceException("Mapping limitation - @JoinColumn on " + fullName() + " needs to map to a primary key as per Issue #529 "
+ " - joining to " + foreignJoinColumn + " and not " + foreignIdColumn);
}
}
} else {
exportedProperties = createExported();
String delStmt = "delete from " + targetDescriptor.baseTable() + " where ";
@@ -726,7 +726,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
*/
@Override
public <T> Junction<T> conjunction(Query<T> query) {
return new JunctionExpression<>(Junction.Type.AND, query, query.where());
return new JunctionExpression<>(Junction.Type.AND, query, this, query.where());
}
/**
@@ -734,7 +734,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
*/
@Override
public <T> Junction<T> disjunction(Query<T> query) {
return new JunctionExpression<>(Junction.Type.OR, query, query.where());
return new JunctionExpression<>(Junction.Type.OR, query, this, query.where());
}
/**
@@ -742,7 +742,7 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
*/
@Override
public <T> Junction<T> conjunction(Query<T> query, ExpressionList<T> parent) {
return new JunctionExpression<>(Junction.Type.AND, query, parent);
return new JunctionExpression<>(Junction.Type.AND, query, this, parent);
}
/**
@@ -750,14 +750,14 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
*/
@Override
public <T> Junction<T> disjunction(Query<T> query, ExpressionList<T> parent) {
return new JunctionExpression<>(Junction.Type.OR, query, parent);
return new JunctionExpression<>(Junction.Type.OR, query, this, parent);
}
/**
* Return a list of expressions that are wrapped by NOT.
*/
public <T> Junction<T> junction(Junction.Type type, Query<T> query) {
return new JunctionExpression<>(type, query, query.where());
return new JunctionExpression<>(type, query, this, query.where());
}
/**
@@ -765,6 +765,6 @@ public class DefaultExpressionFactory implements SpiExpressionFactory {
*/
@Override
public <T> Junction<T> junction(Junction.Type type, Query<T> query, ExpressionList<T> parent) {
return new JunctionExpression<>(type, query, parent);
return new JunctionExpression<>(type, query, this, parent);
}
}
@@ -40,12 +40,8 @@ public class DefaultExpressionList<T> implements SpiExpressionList<T> {
/**
* Construct for Text root expression list - this handles implicit Bool Should, Must etc.
*/
public DefaultExpressionList(Query<T> query) {
this(query, query.getExpressionFactory(), null, new ArrayList<>(), true);
}
public DefaultExpressionList(Query<T> query, ExpressionList<T> parentExprList) {
this(query, query.getExpressionFactory(), parentExprList, new ArrayList<>());
public DefaultExpressionList(Query<T> query, boolean textRoot) {
this(query, query.getExpressionFactory(), null, new ArrayList<>(), textRoot);
}
DefaultExpressionList(Query<T> query, ExpressionFactory expr, ExpressionList<T> parentExprList, List<SpiExpression> list) {
@@ -24,9 +24,9 @@ final class JunctionExpression<T> implements SpiJunction<T>, SpiExpression, Expr
DefaultExpressionList<T> exprList;
Junction.Type type;
JunctionExpression(Junction.Type type, Query<T> query, ExpressionList<T> parent) {
JunctionExpression(Junction.Type type, Query<T> query, ExpressionFactory expr, ExpressionList<T> parent) {
this.type = type;
this.exprList = new DefaultExpressionList<>(query, parent);
this.exprList = new DefaultExpressionList<>(query, expr, parent, new ArrayList<>());
}
/**
@@ -37,12 +37,14 @@ public final class CQueryEngine {
private final CQueryBuilder queryBuilder;
private final CQueryHistorySupport historySupport;
private final DatabasePlatform dbPlatform;
private final boolean autoCommitFalseOnFindIterate;
public CQueryEngine(DatabaseBuilder.Settings config, DatabasePlatform dbPlatform, Binder binder, Map<String, String> asOfTableMapping, Map<String, String> draftTableMap) {
this.dbPlatform = dbPlatform;
this.defaultFetchSizeFindEach = config.getJdbcFetchSizeFindEach();
this.defaultFetchSizeFindList = config.getJdbcFetchSizeFindList();
this.forwardOnlyHintOnFindIterate = dbPlatform.forwardOnlyHintOnFindIterate();
this.autoCommitFalseOnFindIterate = dbPlatform.autoCommitFalseOnFindIterate();
this.historySupport = new CQueryHistorySupport(dbPlatform.historySupport(), asOfTableMapping, config.getAsOfSysPeriod());
this.queryBuilder = new CQueryBuilder(config, dbPlatform, binder, historySupport, new CQueryDraftSupport(draftTableMap));
}
@@ -181,6 +183,9 @@ public final class CQueryEngine {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
if (autoCommitFalseOnFindIterate) {
request.setAutoCommitOnFindIterate();
}
if (!cquery.prepareBindExecuteQueryForwardOnly(forwardOnlyHintOnFindIterate)) {
// query has been cancelled already
return null;
@@ -15,8 +15,8 @@ final class DFetchGroup<T> implements SpiFetchGroup<T> {
}
@Override
public OrmQueryDetail detail() {
return detail.copy();
public OrmQueryDetail detail(OrmQueryDetail existing) {
return detail.copy(existing);
}
@Override
@@ -52,7 +52,7 @@ final class DefaultFetchGroupQuery<T> implements SpiFetchGroupQuery<T>, SpiQuery
@SuppressWarnings("rawtypes")
@Override
public Query<T> select(FetchGroup fetchGroup) {
this.detail = ((SpiFetchGroup) fetchGroup).detail();
this.detail = ((SpiFetchGroup) fetchGroup).detail(detail);
return this;
}
@@ -15,6 +15,8 @@ import io.ebeaninternal.server.core.RowReader;
import io.ebeaninternal.server.persist.Binder;
import jakarta.persistence.PersistenceException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
@@ -28,15 +30,18 @@ public final class DefaultRelationalQueryEngine implements RelationalQueryEngine
private final Binder binder;
private final String dbTrueValue;
private final boolean binaryOptimizedUUID;
private final boolean autoCommitFalseOnFindIterate;
private final TimedMetricMap timedMetricMap;
private final int defaultFetchSizeFindEach;
private final int defaultFetchSizeFindList;
public DefaultRelationalQueryEngine(Binder binder, String dbTrueValue, boolean binaryOptimizedUUID,
int defaultFetchSizeFindEach, int defaultFetchSizeFindList) {
int defaultFetchSizeFindEach, int defaultFetchSizeFindList,
boolean autoCommitFalseOnFindIterate) {
this.binder = binder;
this.dbTrueValue = dbTrueValue == null ? "true" : dbTrueValue;
this.binaryOptimizedUUID = binaryOptimizedUUID;
this.autoCommitFalseOnFindIterate = autoCommitFalseOnFindIterate;
this.timedMetricMap = MetricFactory.get().createTimedMetricMap("sql.query.");
this.defaultFetchSizeFindEach = defaultFetchSizeFindEach;
this.defaultFetchSizeFindList = defaultFetchSizeFindList;
@@ -61,13 +66,20 @@ public final class DefaultRelationalQueryEngine implements RelationalQueryEngine
return "Query threw SQLException:" + msg + " Query was:" + sql;
}
private <T> void prepareForIterate(RelationalQueryRequest request) throws SQLException {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
if (autoCommitFalseOnFindIterate) {
request.setAutoCommitOnFindIterate();
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
}
@Override
public void findEach(RelationalQueryRequest request, RowConsumer consumer) {
try {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
prepareForIterate(request);
request.mapEach(consumer);
request.logSummary();
@@ -82,10 +94,7 @@ public final class DefaultRelationalQueryEngine implements RelationalQueryEngine
@Override
public <T> void findEach(RelationalQueryRequest request, RowReader<T> reader, Predicate<T> consumer) {
try {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
prepareForIterate(request);
while (request.next()) {
if (!consumer.test(reader.read())) {
break;
@@ -17,11 +17,13 @@ public final class DtoQueryEngine {
private final Binder binder;
private final int defaultFetchSizeFindEach;
private final int defaultFetchSizeFindList;
private final boolean autoCommitFalseOnFindIterate;
public DtoQueryEngine(Binder binder, int defaultFetchSizeFindEach, int defaultFetchSizeFindList) {
public DtoQueryEngine(Binder binder, int defaultFetchSizeFindEach, int defaultFetchSizeFindList, boolean autoCommitFalseOnFindIterate) {
this.binder = binder;
this.defaultFetchSizeFindEach = defaultFetchSizeFindEach;
this.defaultFetchSizeFindList = defaultFetchSizeFindList;
this.autoCommitFalseOnFindIterate = autoCommitFalseOnFindIterate;
}
public <T> List<T> findList(DtoQueryRequest<T> request) {
@@ -43,12 +45,19 @@ public final class DtoQueryEngine {
}
}
private <T> void prepareForIterate(DtoQueryRequest<T> request) throws SQLException {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
if (autoCommitFalseOnFindIterate) {
request.setAutoCommitOnFindIterate();
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
}
public <T> QueryIterator<T> findIterate(DtoQueryRequest<T> request) {
try {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
prepareForIterate(request);
return new DtoQueryIterator<>(request);
} catch (SQLException e) {
throw new PersistenceException(errMsg(e.getMessage(), request.getSql()), e);
@@ -57,10 +66,7 @@ public final class DtoQueryEngine {
public <T> void findEach(DtoQueryRequest<T> request, Consumer<T> consumer) {
try {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
prepareForIterate(request);
while (request.next()) {
consumer.accept(request.readNextBean());
}
@@ -73,11 +79,8 @@ public final class DtoQueryEngine {
public <T> void findEach(DtoQueryRequest<T> request, int batchSize, Consumer<List<T>> consumer) {
try {
prepareForIterate(request);
List<T> buffer = new ArrayList<>();
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
while (request.next()) {
buffer.add(request.readNextBean());
if (buffer.size() >= batchSize) {
@@ -98,10 +101,7 @@ public final class DtoQueryEngine {
public <T> void findEachWhile(DtoQueryRequest<T> request, Predicate<T> consumer) {
try {
if (defaultFetchSizeFindEach > 0) {
request.setDefaultFetchBuffer(defaultFetchSizeFindEach);
}
request.executeSql(binder, SpiQuery.Type.ITERATE);
prepareForIterate(request);
while (request.next()) {
if (!consumer.test(request.readNextBean())) {
break;
@@ -769,7 +769,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
copy.useQueryCache = useQueryCache;
copy.unmodifiable = unmodifiable;
if (detail != null) {
copy.detail = detail.copy();
copy.detail = detail.copy(null);
}
copy.temporalMode = temporalMode;
copy.firstRow = firstRow;
@@ -1244,7 +1244,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
public final HashQuery queryHash() {
// calculateQueryPlanHash is called just after potential AutoTune tuning
// so queryPlanHash is calculated well before this method is called
BindValuesKey bindKey = new BindValuesKey();
BindValuesKey bindKey = new BindValuesKey(server);
queryBindKey(bindKey);
return new HashQuery(queryPlanKey, bindKey);
}
@@ -1387,7 +1387,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
@Override
public final Query<T> select(FetchGroup<T> fetchGroup) {
if (fetchGroup != null) {
this.detail = ((SpiFetchGroup<T>) fetchGroup).detail();
this.detail = ((SpiFetchGroup<T>) fetchGroup).detail(detail);
}
return this;
}
@@ -1895,7 +1895,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
public final ExpressionList<T> text() {
if (textExpressions == null) {
useDocStore = true;
textExpressions = new DefaultExpressionList<>(this);
textExpressions = new DefaultExpressionList<>(this, true);
}
return textExpressions;
}
@@ -1903,7 +1903,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
@Override
public final ExpressionList<T> where() {
if (whereExpressions == null) {
whereExpressions = new DefaultExpressionList<>(this, null);
whereExpressions = new DefaultExpressionList<>(this, false);
}
return whereExpressions;
}
@@ -1924,7 +1924,7 @@ public class DefaultOrmQuery<T> extends AbstractQuery implements SpiQuery<T> {
@Override
public final ExpressionList<T> having() {
if (havingExpressions == null) {
havingExpressions = new DefaultExpressionList<>(this, null);
havingExpressions = new DefaultExpressionList<>(this, false);
}
return havingExpressions;
}
@@ -39,12 +39,21 @@ public final class OrmQueryDetail implements Serializable {
/**
* Return a deep copy of the OrmQueryDetail.
*/
public OrmQueryDetail copy() {
public OrmQueryDetail copy(OrmQueryDetail existing) {
OrmQueryDetail copy = new OrmQueryDetail();
copy.baseProps = baseProps.copy();
for (Map.Entry<String, OrmQueryProperties> entry : fetchPaths.entrySet()) {
copy.fetchPaths.put(entry.getKey(), entry.getValue().copy());
}
if (existing != null) {
// transfer any existing filterMany expressions
for (Map.Entry<String, OrmQueryProperties> entry : existing.fetchPaths.entrySet()) {
var filterMany = entry.getValue().getFilterMany();
if (filterMany != null) {
copy.getChunk(entry.getKey(), true).setFilterMany(filterMany);
}
}
}
return copy;
}
@@ -10,7 +10,7 @@ public interface SpiFetchGroup<T> extends FetchGroup<T> {
/**
* Return the detail to use for query execution.
*/
OrmQueryDetail detail();
OrmQueryDetail detail(OrmQueryDetail existing);
/**
* Return the underlying detail for copy purposes.
@@ -20,7 +20,7 @@ public final class DocStoreTransactionManager extends TransactionManager {
@Override
public SpiTransaction createTransaction(boolean explicit, int isolationLevel) {
return createTransaction(explicit, null);
return new DocStoreOnlyTransaction(explicit, this);
}
@Override
@@ -28,8 +28,4 @@ public final class DocStoreTransactionManager extends TransactionManager {
return new DocStoreOnlyTransaction(false, this);
}
@Override
protected SpiTransaction createTransaction(boolean explicit, Connection c) {
return new DocStoreOnlyTransaction(explicit, this);
}
}
@@ -36,7 +36,7 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
/**
* Set false when using autoCommit (as a performance optimisation for the read-only case).
*/
private final boolean useCommit;
private boolean useCommit;
private final TransactionManager manager;
private final SpiTxnLogger logger;
private final boolean logSql;
@@ -200,7 +200,7 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
}
@Override
public void registerDeleteBean(Integer persistingBean) {
public void registerDeleteBean(Class<?> type, Object id) {
throw new IllegalStateException(notExpectedMessage);
}
@@ -208,7 +208,7 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
* Return true if this is a bean that has already been saved/deleted.
*/
@Override
public boolean isRegisteredDeleteBean(Integer persistingBean) {
public boolean isRegisteredDeleteBean(Class<?> type, Object id) {
return false;
}
@@ -550,6 +550,16 @@ final class ImplicitReadOnlyTransaction implements SpiTransaction, TxnProfileEve
throw new IllegalStateException(notExpectedMessage);
}
@Override
public void setAutoCommitOnFindIterate() {
try {
connection.setAutoCommit(false);
useCommit = true;
} catch (SQLException e) {
throw new PersistenceException(e);
}
}
@Override
public void rollbackAndContinue() {
// do nothing
@@ -0,0 +1,32 @@
package io.ebeaninternal.server.transaction;
import org.jspecify.annotations.Nullable;
import java.sql.Connection;
/**
* Ebean transaction used for AutoCommit true connections.
*/
final class JdbcAutoCommitTransaction extends JdbcTransaction {
JdbcAutoCommitTransaction(boolean explicit, Connection connection, @Nullable TransactionManager manager) {
super(true, explicit, connection, manager);
}
@Override
void performRollback() {
long offset = profileOffset();
if (profileStream != null) {
profileStream.addEvent(EVT_ROLLBACK, offset);
}
}
@Override
void performCommit() {
long offset = profileOffset();
if (profileStream != null) {
profileStream.addEvent(EVT_COMMIT, offset);
}
}
}
@@ -68,7 +68,7 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
private int depth;
private boolean autoCommit;
private IdentityHashMap<Object, Object> persistingBeans;
private HashSet<Integer> deletingBeansHash;
private Map<Class<?>, Set<Object>> deletingBeans;
private HashMap<String, String> m2mIntersectionSave;
private Map<String, Object> userObjects;
private List<TransactionCallback> callbackList;
@@ -90,13 +90,17 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
*/
private final boolean skipCacheAfterWrite;
DocStoreTransaction docStoreTxn;
private ProfileStream profileStream;
protected ProfileStream profileStream;
private ProfileLocation profileLocation;
private final Instant startTime = Instant.now();
private final long startNanos;
private boolean autoPersistUpdates;
JdbcTransaction(boolean explicit, Connection connection, TransactionManager manager) {
this(false, explicit, connection, manager);
}
JdbcTransaction(boolean autoCommit, boolean explicit, Connection connection, TransactionManager manager) {
try {
this.active = true;
this.explicit = explicit;
@@ -125,7 +129,9 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
this.onQueryOnlyCommit = true;
}
checkAutoCommit(connection);
if (!autoCommit) {
checkAutoCommit(connection);
}
} catch (Exception e) {
throw new PersistenceException(e);
@@ -328,40 +334,28 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
deferredList.add(derived);
}
/**
* Add a bean to the registed list.
* <p>
* This is to handle bi-directional relationships where both sides Cascade.
* </p>
*/
@Override
public final void registerDeleteBean(Integer persistingBean) {
if (deletingBeansHash == null) {
deletingBeansHash = new HashSet<>();
public final void registerDeleteBean(Class<?> type, Object id) {
deleteBeanIds(type).add(id);
}
@Override
public final boolean isRegisteredDeleteBean(Class<?> type, Object id) {
return deleteBeanIds(type).contains(id);
}
private Set<Object> deleteBeanIds(Class<?> type) {
if (deletingBeans == null) {
deletingBeans = new HashMap<>();
}
deletingBeansHash.add(persistingBean);
return deletingBeans.computeIfAbsent(type, k -> new HashSet<>());
}
/**
* Return true if this is a bean that has already been saved/deleted.
*/
@Override
public final boolean isRegisteredDeleteBean(Integer persistingBean) {
return deletingBeansHash != null && deletingBeansHash.contains(persistingBean);
}
/**
* Unregister the persisted beans (when persisting at the top level).
*/
@Override
public final void unregisterBeans() {
persistingBeans.clear();
}
/**
* Return true if this is a bean that has already been saved. This will
* register the bean if it is not already.
*/
@Override
public final boolean isRegisteredBean(Object bean) {
if (persistingBeans == null) {
@@ -370,10 +364,6 @@ class JdbcTransaction implements SpiTransaction, TxnProfileEventCodes {
return (persistingBeans.put(bean, PLACEHOLDER) != null);
}
/**
* Return true if the m2m intersection save is allowed from a given bean direction.
* This is to stop m2m intersection management via both directions of a m2m.
*/
@Override
public final boolean isSaveAssocManyIntersection(String intersectionTable, String beanName) {
if (m2mIntersectionSave == null) {
@@ -154,12 +154,12 @@ final class NoTransaction implements SpiTransaction {
}
@Override
public void registerDeleteBean(Integer hash) {
public void registerDeleteBean(Class<?> type, Object id) {
}
@Override
public boolean isRegisteredDeleteBean(Integer hash) {
public boolean isRegisteredDeleteBean(Class<?> type, Object id) {
return false;
}
@@ -13,9 +13,18 @@ import java.sql.SQLException;
abstract class TransactionFactory {
final TransactionManager manager;
private final boolean autoCommitMode;
TransactionFactory(TransactionManager manager) {
this.manager = manager;
this.autoCommitMode = manager.isAutoCommitMode();
}
/**
* Return a new transaction.
*/
SpiTransaction createTransaction(boolean explicit, Connection connection) {
return autoCommitMode ? new JdbcAutoCommitTransaction(explicit, connection, manager) : new JdbcTransaction(explicit, connection, manager);
}
/**
@@ -34,7 +43,7 @@ abstract class TransactionFactory {
/**
* Set the Transaction Isolation level if required.
*/
final SpiTransaction setIsolationLevel(SpiTransaction t, boolean explicit, int isolationLevel) {
final SpiTransaction setIsolationLevel(SpiTransaction t, int isolationLevel) {
if (isolationLevel > -1) {
Connection connection = t.internalConnection();
try {
@@ -39,8 +39,8 @@ class TransactionFactoryBasic extends TransactionFactory {
Connection connection = null;
try {
connection = dataSource.getConnection();
SpiTransaction t = create(explicit, connection);
return setIsolationLevel(t, explicit, isolationLevel);
SpiTransaction t = createTransaction(explicit, connection);
return setIsolationLevel(t, isolationLevel);
} catch (PersistenceException ex) {
JdbcClose.close(connection);
throw ex;
@@ -49,8 +49,4 @@ class TransactionFactoryBasic extends TransactionFactory {
}
}
private SpiTransaction create(boolean explicit, Connection c) {
return manager.createTransaction(explicit, c);
}
}
@@ -25,26 +25,32 @@ class TransactionFactoryTenant extends TransactionFactory {
@Override
public SpiTransaction createReadOnlyTransaction(Object tenantId, boolean useMaster) {
return create(false, tenantId);
Connection connection = null;
try {
if (tenantId == null) {
tenantId = tenantProvider.currentId();
}
connection = dataSourceSupplier.readOnlyConnection(tenantId, useMaster);
return new ImplicitReadOnlyTransaction(manager, connection, tenantId);
} catch (PersistenceException ex) {
JdbcClose.close(connection);
throw ex;
} catch (SQLException ex) {
throw new PersistenceException(ex);
}
}
@Override
public final SpiTransaction createTransaction(boolean explicit, int isolationLevel) {
SpiTransaction t = create(explicit, null);
return setIsolationLevel(t, explicit, isolationLevel);
}
private SpiTransaction create(boolean explicit, Object tenantId) {
Connection connection = null;
try {
if (tenantId == null) {
// tenantId not set (by lazy loading) so get current tenantId
tenantId = tenantProvider.currentId();
}
Object tenantId = tenantProvider.currentId();
connection = dataSourceSupplier.connection(tenantId);
SpiTransaction transaction = manager.createTransaction(explicit, connection);
SpiTransaction transaction = createTransaction(explicit, connection);
transaction.setTenantId(tenantId);
return transaction;
return setIsolationLevel(transaction, isolationLevel);
} catch (PersistenceException ex) {
JdbcClose.close(connection);
@@ -5,12 +5,12 @@ import io.ebean.BackgroundExecutor;
import io.ebean.ProfileLocation;
import io.ebean.TxScope;
import io.ebean.annotation.PersistBatch;
import io.ebean.annotation.Platform;
import io.ebean.annotation.TxType;
import io.ebean.cache.ServerCacheNotification;
import io.ebean.cache.ServerCacheNotify;
import io.ebean.config.CurrentTenantProvider;
import io.ebean.config.dbplatform.DatabasePlatform;
import io.ebean.datasource.DataSourcePool;
import io.ebean.event.changelog.ChangeLogListener;
import io.ebean.event.changelog.ChangeLogPrepare;
import io.ebean.event.changelog.ChangeSet;
@@ -106,6 +106,7 @@ public class TransactionManager implements SpiTransactionManager {
private final ServerCacheNotify cacheNotify;
private final boolean supportsSavepointId;
private final ConcurrentHashMap<String, ProfileLocation> profileLocations = new ConcurrentHashMap<>();
private final boolean autoCommitMode;
/**
* Create the TransactionManager
@@ -115,6 +116,7 @@ public class TransactionManager implements SpiTransactionManager {
this.logManager = options.logManager;
this.databasePlatform = options.config.getDatabasePlatform();
this.supportsSavepointId = databasePlatform.supportsSavepointId();
this.autoCommitMode = databasePlatform.platform() == Platform.CLICKHOUSE;
this.skipCacheAfterWrite = options.config.isSkipCacheAfterWrite();
this.notifyL2CacheInForeground = options.notifyL2CacheInForeground;
this.autoPersistUpdates = options.config.isAutoPersistUpdates();
@@ -206,6 +208,10 @@ public class TransactionManager implements SpiTransactionManager {
}
}
final boolean isAutoCommitMode() {
return autoCommitMode;
}
/**
* Return true if the DB platform supports SavepointId().
*/
@@ -298,13 +304,6 @@ public class TransactionManager implements SpiTransactionManager {
return transactionFactory.createReadOnlyTransaction(tenantId, useMaster);
}
/**
* Create a new transaction.
*/
SpiTransaction createTransaction(boolean explicit, Connection c) {
return new JdbcTransaction(explicit, c, this);
}
/**
* Process a local rolled back transaction.
*/
+2 -3
View File
@@ -31,6 +31,7 @@ module io.ebean.core {
requires io.ebean.types;
requires static io.avaje.jsr305x;
requires static io.ebean.core.json;
requires static com.fasterxml.jackson.annotation;
requires static com.fasterxml.jackson.core;
requires static com.fasterxml.jackson.databind;
@@ -49,7 +50,6 @@ module io.ebean.core {
exports io.ebeaninternal.api to io.ebean.ddl.generator, io.ebean.querybean, io.ebean.autotune, io.ebean.postgis, io.ebean.test, io.ebean.elastic, io.ebean.spring.txn, io.ebean.postgis.types;
exports io.ebeaninternal.api.json to io.ebean.test;
exports io.ebeaninternal.json to io.ebean.test;
exports io.ebeaninternal.server.autotune to io.ebean.autotune;
exports io.ebeaninternal.server.core to io.ebean.test, io.ebean.elastic;
exports io.ebeaninternal.server.core.bootup to io.ebean.test;
@@ -78,7 +78,6 @@ module io.ebean.core {
io.ebeaninternal.server.query.DFetchGroupService,
io.ebeaninternal.server.profile.DProfileLocationFactory,
io.ebeaninternal.server.rawsql.DRawSqlService,
io.ebeaninternal.server.profile.DMetricFactory,
io.ebeaninternal.json.DJsonService;
io.ebeaninternal.server.profile.DMetricFactory;
}
@@ -3,4 +3,3 @@ io.ebeaninternal.server.rawsql.DRawSqlService
io.ebeaninternal.server.query.DFetchGroupService
io.ebeaninternal.server.profile.DProfileLocationFactory
io.ebeaninternal.server.profile.DMetricFactory
io.ebeaninternal.json.DJsonService
@@ -70,7 +70,7 @@ public class RawExpressionTest extends BaseExpressionTest {
}
private BindValuesKey bindKey(RawExpression query) {
BindValuesKey bindValuesKey = new BindValuesKey();
BindValuesKey bindValuesKey = new BindValuesKey(spiEbeanServer());
query.queryBindKey(bindValuesKey);
return bindValuesKey;
}
@@ -1,19 +1,20 @@
package io.ebeaninternal.server.querydefn;
import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.server.deploy.BaseTest;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BindValuesKeyTest {
public class BindValuesKeyTest extends BaseTest {
@Test
public void update_with_null() {
BindValuesKey hash = new BindValuesKey();
BindValuesKey hash = new BindValuesKey(spiEbeanServer());
hash.add(1).add(null).add("hello");
BindValuesKey hash2 = new BindValuesKey();
BindValuesKey hash2 = new BindValuesKey(spiEbeanServer());
hash2.add(1).add(null).add("hello");
assertThat(hash).isEqualTo(hash2);
@@ -22,13 +23,13 @@ public class BindValuesKeyTest {
@Test
public void notEqual() {
BindValuesKey hash = new BindValuesKey();
BindValuesKey hash = new BindValuesKey(spiEbeanServer());
hash.add(1).add(null).add("hello");
BindValuesKey hash2 = new BindValuesKey();
BindValuesKey hash2 = new BindValuesKey(spiEbeanServer());
hash2.add(1).add("hello");
BindValuesKey hash3 = new BindValuesKey();
BindValuesKey hash3 = new BindValuesKey(spiEbeanServer());
hash2.add(1).add(null);
assertThat(hash).isNotEqualTo(hash2);
@@ -139,7 +139,7 @@ public class DefaultOrmQueryTest extends BaseExpressionTest {
}
private BindValuesKey bindKey(DefaultOrmQuery<Order> query) {
BindValuesKey key = new BindValuesKey();
BindValuesKey key = new BindValuesKey(spiEbeanServer());
query.queryBindKey(key);
return key;
}
+4 -4
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean ddl generation</name>
@@ -28,14 +28,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -65,7 +65,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -195,7 +195,7 @@ public class ModelBuildPropertyVisitor extends BaseTablePropertyVisitor {
String dbCol = column.getLocalDbColumn();
BeanProperty importedProperty = p.findMatchImport(dbCol);
if (importedProperty == null) {
throw new RuntimeException("Imported BeanProperty not found?");
continue;
}
String columnDefn = ctx.getColumnDefn(importedProperty, true);
String refColumn = importedProperty.dbColumn();
+3 -2
View File
@@ -3,18 +3,19 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ebean-jackson-mapper</artifactId>
<name>ebean-jackson-mapper</name>
<dependencies>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core-type</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
+4 -4
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean net postgis types</name>
@@ -19,14 +19,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<!-- provided scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -54,7 +54,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
+4 -4
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean postgis types</name>
@@ -19,14 +19,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-postgres</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<!-- provided scope -->
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -62,7 +62,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
+5 -5
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean querybean</name>
@@ -17,7 +17,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -59,14 +59,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -80,7 +80,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -121,7 +121,7 @@ public abstract class QueryBean<T, R extends QueryBean<T, R>> implements IQueryB
/** Construct for FilterMany */
protected QueryBean(ExpressionList<T> filter) {
this.query = null;
this.root = null;
this.root = (R) this;
this.whereStack = new ArrayStack<>();
whereStack.push(filter);
}
@@ -13,6 +13,7 @@ import org.example.domain.otherpackage.ValidEmail;
import org.example.domain.query.QContact;
import org.example.domain.query.QCustomer;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import javax.sql.DataSource;
@@ -377,6 +378,37 @@ public class QCustomerTest {
assertThat(q.getGeneratedSql()).contains(" from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where (t1.id is null or (t1.first_name like ? and t1.first_name like ? escape'|')) order by t0.id");
}
@Test
void filterManyOr() {
var q = new QCustomer()
.contacts.filterMany(c ->
c.or()
.firstName.startsWith("R")
.lastName.startsWith("R")
.endOr())
.query();
q.findList();
assertThat(q.getGeneratedSql()).contains(" from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where (t1.id is null or ((t1.first_name like ? escape'|' or t1.last_name like ? escape'|'))) order by t0.id");
}
@Test
@DisplayName("Retain filterMany expression when select fetchGroup applied after filterMany")
void filterManyBeforeSelectFetchGroup_expect_filterManyExpressionRetained() {
var fetchGroup = QCustomer.forFetchGroup()
.select(name)
.contacts.fetch(QContact.Alias.email)
.buildFetchGroup();
var q = new QCustomer()
.contacts.filterMany(c -> c.firstName.startsWith("R"))
.select(fetchGroup)
.query();
q.findList();
assertThat(q.getGeneratedSql()).contains(" t0.id, t0.name, t1.id, t1.email from be_customer t0 left join be_contact t1 on t1.customer_id = t0.id where (t1.id is null or (t1.first_name like ? escape'|')) order by t0.id");
}
@Test
public void testIdIn() {
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<artifactId>ebean-redis</artifactId>
@@ -29,35 +29,35 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-api</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>querybean-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
+3 -3
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<artifactId>ebean-spring-txn</artifactId>
@@ -28,7 +28,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
@@ -77,7 +77,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-test</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>ebean test</name>
@@ -33,20 +33,20 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</dependency>
<dependency>
@@ -149,14 +149,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-jackson-mapper</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-all</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -5,7 +5,7 @@ import io.ebean.test.containers.PostgresContainer;
public class StartPostgres {
public static void main(String[] args) {
PostgresContainer.builder("15")
PostgresContainer.builder("17")
.dbName("unit")
//.port(6432)
//.user("unit")
@@ -2,14 +2,15 @@ package org.tests.basic;
import io.ebean.*;
import io.ebean.annotation.Platform;
import io.ebean.annotation.TxIsolation;
import io.ebean.test.LoggedSql;
import io.ebean.xtest.BaseTestCase;
import io.ebean.xtest.ForPlatform;
import io.ebean.xtest.IgnorePlatform;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.Customer;
import org.tests.model.basic.EBasic;
import org.tests.model.basic.Order;
import org.tests.model.basic.ResetBasicData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.tests.model.basic.*;
import java.util.List;
@@ -18,6 +19,8 @@ import static org.junit.jupiter.api.Assertions.*;
public class TestQueryForUpdate extends BaseTestCase {
private static final Logger log = LoggerFactory.getLogger(TestQueryForUpdate.class);
@Test
public void testForUpdate() {
@@ -41,54 +44,99 @@ public class TestQueryForUpdate extends BaseTestCase {
}
}
// Nah, nothing to do with repeatable read here
// @ForPlatform(Platform.YUGABYTE)
// @Test
// void concurrentForUpdate() throws InterruptedException {
// ResetBasicData.reset();
//
// Database db = DB.getDefault();
// Thread t1 = new Thread() {
// @Override
// public void run() {
// try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
// log.info("(REPEATABLE_READ) Thread: before find");
// List<Country> list = DB.find(Country.class)
// .usingTransaction(transaction)
// .forUpdate()
// .findList();
//
// try {
// log.info("(REPEATABLE_READ) Thread: after find - size:{}, hold locks for some time", list.size());
// Thread.sleep(500);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// log.info("(REPEATABLE_READ) Thread: done, release locks");
// }
// }
// };
//
// t1.start();
// Thread.sleep(100);
//
// long start = System.currentTimeMillis();
// try (final Transaction transaction = db.createTransaction(TxIsolation.REPEATABLE_READ)) {
// log.info("(REPEATABLE_READ) Main: before find, should wait for locks to be released...");
// DB.find(Country.class)
// .usingTransaction(transaction)
// .forUpdate()
// .findList();
//
// log.info("(REPEATABLE_READ) Main: complete");
// }
//
// long exeMillis = System.currentTimeMillis() - start;
// assertThat(exeMillis).isGreaterThan(300);
// }
// @IgnorePlatform(Platform.YUGABYTE) // ignore this for yugabyte and see if everything else passes
@Test
public void testConcurrentForUpdate() throws InterruptedException {
ResetBasicData.reset();
Thread t1 = new Thread() {
@Override
public void run() {
try (final Transaction transaction = DB.beginTransaction()) {
System.out.println("Thread: before find");
DB.find(Customer.class)
.forUpdate()
// .orderBy().desc("1") // this would help by the locks in DB2
.findList();
Database db = DB.getDefault();
Thread t1 = new Thread(() -> {
try (final Transaction transaction = db.createTransaction()) {
log.info("Thread: before find");
List<Customer> list = DB.find(Customer.class)
.usingTransaction(transaction)
.forUpdate()
.findList();
System.out.println("Thread: after find");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
System.out.println("Thread: done");
try {
log.info("Thread: after find - rows locked:{}, hold for 700ms", list.size());
Thread.sleep(600); // 3000
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
};
log.info("Thread: done, releasing locks");
} // transaction ended here via try-with-resources
});
t1.start();
Thread.sleep(100);
long start = System.currentTimeMillis();
try (final Transaction transaction = DB.beginTransaction()) {
try (final Transaction transaction = db.beginTransaction()) { // second transaction
if (isH2()) {
DB.sqlUpdate("SET LOCK_TIMEOUT 5000").execute();
}
System.out.println("Main: before find");
log.info("Main: before find, should wait (blocked by other thread) ...");
DB.find(Customer.class)
.usingTransaction(transaction)
.forUpdate()
//.orderBy().desc("1") // this would help by the locks in DB2
.findList();
System.out.println("Main: after find");
}
start = System.currentTimeMillis() - start;
assertThat(start).isGreaterThan(2800);
log.info("Main: complete");
} // end second transaction
long exeMillis = System.currentTimeMillis() - start;
assertThat(exeMillis)
.describedAs("select for update expected to wait")
.isGreaterThan(400); // 2500
}
@Test
@@ -1,13 +1,16 @@
package org.tests.el;
import io.ebean.annotation.Platform;
import io.ebean.xtest.BaseTestCase;
import io.ebean.DB;
import io.ebean.Query;
import io.ebean.xtest.IgnorePlatform;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.Customer;
class TestRawExpressionInterpolation extends BaseTestCase {
@IgnorePlatform({Platform.ORACLE, Platform.DB2})
@Test
void test() {
@@ -56,7 +56,6 @@ public class TestCarWheelIud extends BaseTestCase {
Car car2 = DB.find(Car.class, car.getId());
DB.delete(car2);
}
@Test
@@ -0,0 +1,45 @@
package org.tests.model.m2o;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
@Entity
public class MTJOrder {
@Id
private long id;
@Column(name = "org_id")
private long orgId;
@Column
private String other;
public Long id() {
return id;
}
public MTJOrder setId(Long id) {
this.id = id;
return this;
}
public Long orgId() {
return orgId;
}
public MTJOrder setOrgId(Long orgId) {
this.orgId = orgId;
return this;
}
public String other() {
return other;
}
public MTJOrder setOther(String other) {
this.other = other;
return this;
}
}
@@ -0,0 +1,47 @@
package org.tests.model.m2o;
import jakarta.persistence.*;
@Entity
public class MTJTrans {
@Id
private long id;
@Column(name = "org_id")
private long orgId;
@ManyToOne
@JoinColumns({
@JoinColumn(name = "org_id", referencedColumnName = "org_id"), // extra join column, not strictly needed
@JoinColumn(name = "order_id", referencedColumnName = "id")
})
private MTJOrder order;
public Long id() {
return id;
}
public MTJTrans setId(Long id) {
this.id = id;
return this;
}
public Long orgId() {
return orgId;
}
public MTJTrans setOrgId(Long orgId) {
this.orgId = orgId;
return this;
}
public MTJOrder order() {
return order;
}
public MTJTrans setOrder(MTJOrder order) {
this.order = order;
return this;
}
}
@@ -0,0 +1,48 @@
package org.tests.model.m2o;
import io.ebean.DB;
import io.ebean.test.LoggedSql;
import org.junit.jupiter.api.Test;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
class TestMTJoinColumns {
@Test
void test() {
MTJTrans parent = new MTJTrans();
parent.setOrgId(51L);
DB.save(parent);
MTJTrans found = DB.find(MTJTrans.class)
.setId(parent.id())
.fetch("order")
.findOne();
assertThat(found.order()).isNull();
var order = new MTJOrder()
.setOrgId(51L)
.setOther("some");
DB.save(order);
found.setOrder(order);
DB.save(found);
LoggedSql.start();
MTJTrans found2 = DB.find(MTJTrans.class)
.setId(parent.id())
.fetch("order")
.findOne();
assertThat(found2.order()).isNotNull();
assertThat(found2.order().id()).isEqualTo(order.id());
assertThat(found2.order().other()).isEqualTo("some");
List<String> sql = LoggedSql.stop();
assertThat(sql).hasSize(1);
assertThat(sql.get(0)).contains("from mtjtrans t0 left join mtjorder t1 on t1.org_id = t0.org_id and t1.id = t0.order_id where t0.id = ?");
}
}
@@ -0,0 +1,21 @@
package org.tests.model.memleak;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
/**
* Class with @Cache(enableQueryCache = true)
*
* @author Jonas Fr&ouml;hler, FOCONIS AG
*/
@Entity
public class MemleakChild {
@Id
Long id;
String name;
transient byte[] memConsumer = new byte[1000000];
}
@@ -0,0 +1,25 @@
package org.tests.model.memleak;
import io.ebean.annotation.Cache;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.ManyToOne;
/**
* Class that holds the {@link MemleakChild}.
*
* @author Jonas Fr&ouml;hler, Foconis Analytics GmbH
*/
@Entity
@Cache(enableQueryCache = true)
public class MemleakParent {
@Id
Long id;
@ManyToOne()
MemleakChild child;
String name;
}
@@ -0,0 +1,37 @@
package org.tests.model.memleak;
import io.ebean.DB;
import io.ebean.xtest.BaseTestCase;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
/**
* The query cache holds the bean (MemleakChild). If there are "big" beans, then an OOM may occur.
*
* @author Jonas Fr&ouml;hler, Foconis Analytics GmbH
*/
public class TestQueryCacheHoldsBean extends BaseTestCase {
@Test
@Disabled("Run manually with -Xmx128M")
void testQueryCacheHoldsBean() {
for (long id = 0; id <= 1000; id++) {
DB.find(MemleakParent.class)
.where().eq("id", id)
.eq("child", DB.reference(MemleakChild.class, id))
.setUseQueryCache(true)
.findOne();
}
}
@Test
void queryCacheHoldsBean() {
var query = DB.find(MemleakParent.class)
.where().eq("id", 989898)
.eq("child", DB.reference(MemleakChild.class, 4534535))
.setUseQueryCache(true);
query.findOne();
query.findOne();
}
}
@@ -6,9 +6,11 @@ import org.tests.model.basic.EBasic.Status;
* DTO for Ebasic Queries.
*/
public class EBasicDto {
private Integer id;
private Integer id;
private Status status;
private String name;
private String description;
public Integer getId() {
return id;
@@ -25,4 +27,22 @@ public class EBasicDto {
public void setStatus(Status status) {
this.status = status;
}
}
public String getName() {
return name;
}
public EBasicDto setName(String name) {
this.name = name;
return this;
}
public String getDescription() {
return description;
}
public EBasicDto setDescription(String description) {
this.description = description;
return this;
}
}
@@ -6,7 +6,8 @@ import io.ebean.DB;
import io.ebean.Database;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.tests.model.basic.EBasic;
// import org.tests.model.basic.EBasic;
import org.tests.query.cancel.EBasicDto;
import javax.management.MBeanServer;
import java.io.File;
@@ -30,57 +31,50 @@ public class TestFindIterateHeapDump extends BaseTestCase {
*/
@Disabled
@Test
public void test() {
void test() {
Database server = DB.getDefault();
// Transaction transaction = server.beginTransaction();
// try {
// String desc = "0123456789".repeat(20);
// try (Transaction transaction = server.beginTransaction()){
// transaction.setBatchMode(true);
// transaction.setBatchSize(20);
// for (int i = 0; i < 20000; i++) {
// transaction.setBatchSize(100);
// for (int i = 0; i < 200_000; i++) {
// EBasic dumbModel = new EBasic();
// dumbModel.setName("Goodbye now");
// dumbModel.setDescription(desc);
// server.save(dumbModel);
// }
// transaction.commit();
//
// } finally {
// transaction.end();
// }
//
// if (true) {
// return;
// }
// Intentionally not iterating through the iterator to
final AtomicInteger counter = new AtomicInteger();
server.find(EBasic.class)
.findEach(bean -> {
server.sqlQuery("select id, status, name, description from e_basic")
.findEach(bean -> {
// server.findDto(EBasicDto.class, "select id, status, name, description from e_basic")
// .findStream().forEach(bean -> {
// server.find(EBasic.class)
// .findEach(bean -> {
// server.find(EBasic.class)
// .setBufferFetchSizeHint(10)
// .findStream().forEach(bean -> {
// .findEach(bean -> {
int count = counter.incrementAndGet();
if (count == 1) {
dumpHeap("heap-dump13-initial.snapshot", true);
if (count == 10) {
dumpHeap("s1-dump-initial.snapshot.hprof", true);
}
if (count == (200_000 - 100)) {
dumpHeap("s1-dump-end.snapshot.hprof", true);
}
});
// try {
// while (iterate.hasNext()) {
// EBasic eBasic = iterate.next();
// eBasic.getDescription();
// }
// } finally {
// iterate.close();
// }
String fileName = "heap-dump13.snapshot";
String fileName = "s1-dump.snapshot.hprof";
File file = new File(fileName);
if (file.exists())
if (file.exists()) {
file.delete();
}
dumpHeap(fileName, true);
}
@@ -1,5 +1,5 @@
ebean.test.platform=yugabyte
datasource.default=yugabyte
ebean.test.dbName=unit
ebean.test.yugabyte.version=2.18.0.0-b65
ebean.test.yugabyte.version=2.20.11.0-b34
ebean.lengthCheck=on
+4 -4
View File
@@ -15,8 +15,8 @@ mvn -T 4 clean package
mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests
## git commit, git tag, git push --tags
git commit -am 'Version 16.0.0-rc3'
git tag 16.0.0-rc3
git commit -am 'Version 16.1.0'
git tag 16.1.0
git push --tags
## convert to javax
@@ -27,7 +27,7 @@ mvs
## deploy javax
mvn -T 4 clean package
mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests -DskipStagingRepositoryClose=true -DstagingProgressTimeoutMinutes=9
mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests
## checkout / cleanup
git checkout .
@@ -45,7 +45,7 @@ mvs
## build and deploy 15.x
mvn -T 4 clean package
mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests -DskipStagingRepositoryClose=true -DstagingProgressTimeoutMinutes=9
mvn -T 4 deploy -pl '!composites,!platforms' -Pcentral -DskipTests
```
+6 -6
View File
@@ -4,7 +4,7 @@
<parent>
<artifactId>ebean-parent</artifactId>
<groupId>io.ebean</groupId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
</parent>
<name>kotlin querybean generator</name>
@@ -21,7 +21,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-querybean</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -35,7 +35,7 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-core</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -56,14 +56,14 @@
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-platform-h2</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.ebean</groupId>
<artifactId>ebean-ddl-generator</artifactId>
<version>16.0.0-RC3</version>
<version>16.1.0</version>
<scope>test</scope>
</dependency>
@@ -83,7 +83,7 @@
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<version>2.2.10</version>
<executions>
<execution>
<id>test-compile</id>
@@ -5,6 +5,9 @@ interface Constants {
String AT_GENERATED = "@io.ebean.typequery.Generated(\"io.ebean.querybean.kotlin-generator\")";
String AT_TYPEQUERYBEAN = "@io.ebean.typequery.TypeQueryBean(\"v1\")";
String GENERATED = "io.ebean.typequery.Generated";
String TYPEQUERYBEAN = "io.ebean.typequery.TypeQueryBean";
String MAPPED_SUPERCLASS = "jakarta.persistence.MappedSuperclass";
String DISCRIMINATOR_VALUE = "jakarta.persistence.DiscriminatorValue";
String INHERITANCE = "jakarta.persistence.Inheritance";
@@ -24,6 +27,6 @@ interface Constants {
String METAINF_MANIFEST = "META-INF/ebean-generated-info.mf";
String METAINF_SERVICES_MODULELOADER = "META-INF/services/io.ebean.config.EntityClassRegister";
String AVAJE_LANG_NULLABLE = "io.avaje.lang.Nullable";
String AVAJE_LANG_NULLABLE = "org.jspecify.annotations.Nullable";
String JAVA_COLLECTION = "java.util.Collection";
}
@@ -49,6 +49,8 @@ public class Processor extends AbstractProcessor implements Constants {
annotations.add(CONVERTER);
annotations.add(EBEAN_COMPONENT);
annotations.add(MODULEINFO);
annotations.add(TYPEQUERYBEAN);
annotations.add(GENERATED);
return annotations;
}

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